Пример #1
0
def invite_friend(request, event_id):
  if request.method == 'POST':
    event = Event.objects.get(pk=event_id)
    selected_friendList = request.POST.getlist('friendList')

    for selected_friend_id in selected_friendList:
      selected_friend = User.objects.get(pk=selected_friend_id)     
      attendence = Attendence()
      attendence.participant = selected_friend
      attendence.event = event
      isInvited = True
      attendence.save()
      
    return HttpResponseRedirect(("../../{}").format(event_id))

  else:
    friendProfileList = request.user.get_profile().friends.all()
    friendList = []
  
    if friendProfileList.exists():
      for friendProfile in friendProfileList:    
        attendence = Attendence.objects \
             .filter(event_id=event_id,participant=friendProfile.user)[:1]  
        if len(attendence) == 0:
          friendList.append(friendProfile.user)

    return render(request, 'eventdapp/invite.html',{
      'friendList' : friendList,
      'event_id' : event_id,
    })
Пример #2
0
def view_event(request, event_id):
    event = Event.objects.get(pk=event_id)
    owner_id = event.owner.id

    #determine whether the user has activated the participation status
    attendence = Attendence.objects.filter(event__pk=event.id,
                                           participant__pk=request.user.id)

    attendence_choices = Attendence.get_remaining_choices(
        attendence[0].participation if attendence.exists() else None)
    template_vars = {
      'event': event,
      'attendence_choices': attendence_choices,
      'is_own': (request.user.id == owner_id),
      'share_subject': 'Check out this event!',
      'share_body': "Check out the event at" + '%0D%0A%0D%0A' + \
                    request.build_absolute_uri(),
      }
    if attendence.exists():
        template_vars['status'] = attendence[0].get_participation_display()

    template = 'eventdapp/event.%s' % ext_from(request)

    return render(request, template, template_vars, \
                  content_type=content_type_from(request))
Пример #3
0
def invite_friend(request, event_id):
    if request.method == 'POST':
        event = Event.objects.get(pk=event_id)
        selected_friendList = request.POST.getlist('friendList')

        for selected_friend_id in selected_friendList:
            selected_friend = User.objects.get(pk=selected_friend_id)
            attendence = Attendence()
            attendence.participant = selected_friend
            attendence.event = event
            isInvited = True
            attendence.save()

        return HttpResponseRedirect(("../../{}").format(event_id))

    else:
        friendProfileList = request.user.get_profile().friends.all()
        friendList = []

        if friendProfileList.exists():
            for friendProfile in friendProfileList:
                attendence = Attendence.objects \
                     .filter(event_id=event_id,participant=friendProfile.user)[:1]
                if len(attendence) == 0:
                    friendList.append(friendProfile.user)

        return render(request, 'eventdapp/invite.html', {
            'friendList': friendList,
            'event_id': event_id,
        })
Пример #4
0
def attend_event(request, event_id, is_going):
    event = Event.objects.get(pk=event_id)
    attendence = Attendence.objects.filter(event__pk=event.id,
                                           participant__pk=request.user.id)
    user = request.user

    is_going = is_going.upper()
    if not Attendence.is_valid_participation(is_going):
        raise Http404

    if not attendence.exists():
        new_attendence = Attendence()
        new_attendence.participant = user
        new_attendence.event = event
        new_attendence.participation = is_going
        new_attendence.save()
    elif attendence.exists():
        att = attendence[0]
        att.participation = is_going
        att.save()

    return HttpResponseRedirect(("../../../{}").format(event.id))
Пример #5
0
def attend_event(request, event_id, is_going):
  event = Event.objects.get(pk=event_id)
  attendence = Attendence.objects.filter(event__pk = event.id, participant__pk = request.user.id)
  user = request.user

  is_going = is_going.upper()
  if not Attendence.is_valid_participation(is_going):
    raise Http404

  if not attendence.exists():
    new_attendence = Attendence()
    new_attendence.participant = user
    new_attendence.event = event
    new_attendence.participation = is_going
    new_attendence.save()    
  elif attendence.exists():
    att = attendence[0]
    att.participation = is_going
    att.save()
    
  return HttpResponseRedirect(("../../../{}").format(event.id))
Пример #6
0
def view_event(request, event_id):
  event = Event.objects.get(pk=event_id)
  owner_id = event.owner.id
  
  #determine whether the user has activated the participation status
  attendence = Attendence.objects.filter(event__pk = event.id, participant__pk = request.user.id)
  
  attendence_choices = Attendence.get_remaining_choices(
                          attendence[0].participation if attendence.exists() else None)
  template_vars = {
    'event': event,
    'attendence_choices': attendence_choices,
    'is_own': (request.user.id == owner_id),
    'share_subject': 'Check out this event!',
    'share_body': "Check out the event at" + '%0D%0A%0D%0A' + \
                  request.build_absolute_uri(),
    }
  if attendence.exists():
    template_vars['status'] = attendence[0].get_participation_display()

  template = 'eventdapp/event.%s' % ext_from(request)

  return render(request, template, template_vars, \
                content_type=content_type_from(request))