~dholbach/loco-team-portal/profile

« back to all changes in this revision

Viewing changes to loco_directory/events/views.py

  • Committer: Daniel Holbach
  • Date: 2010-08-24 15:24:24 UTC
  • Revision ID: daniel.holbach@canonical.com-20100824152424-ph3l1e0he33oix2p
make events work with new profile infrastructure

Show diffs side-by-side

added added

removed removed

Lines of Context:
304
304
    """
305
305
    team_event_object = get_object_or_404(TeamEvent, pk=team_event_id)
306
306
    if team_event_object.is_attending(request.user):
307
 
        attendee_object = team_event_object.attendee_set.get(attendee=request.user)
 
307
        attendee_object = team_event_object.attendee_set.get(attendee_profile__user=request.user)
308
308
    else:
309
 
        attendee_object = Attendee(team_event=team_event_object, attendee=request.user)
 
309
        from userprofiles.models import create_profile
 
310
        profile = create_profile(request.user.username)
 
311
        attendee_object = Attendee(team_event=team_event_object, attendee_profile=profile)
310
312
        
311
313
    if request.method == 'POST':        
312
314
        form = AttendeeRegistrationForm(instance=attendee_object, data=request.POST)
341
343
        if form.is_valid():
342
344
            team_event_comment = form.save(commit=False)
343
345
            team_event_comment.team_event = team_event_object
344
 
            team_event_comment.comment_by = request.user
 
346
            from userprofiles.models import create_profile
 
347
            profile = create_profile(request.user.username)
 
348
            team_event_comment.commenter_profile = profile
345
349
            team_event_comment.save()
346
350
            request.user.message_set.create(message=_('Comment saved.'))
347
351
            return redirect( team_event_object )