Пример #1
0
 def wrapper(*args, **kwargs):
   request = args[0]
   event_id = kwargs['event_id'] 
   requestingUser = getUserForTicket(request)
   event_goers = EventGoer.objects.filter(
     user=requestingUser, event__id=event_id,
     state=u'IE')
   if not event_goers.exists():
     return HttpResponseForbidden(
       "You must be logged into the party to do that")
   elif event_goers[0].event.state == u'FN':
     response = HttpResponse(status=410)
     response[getGoneResourceHeader()] = "event"
     return response
   else:
     return function(*args, **kwargs)
Пример #2
0
def joinEvent(request, event_id, user_id):

  event_to_join = Event.objects.get(pk=event_id)
  if event_to_join.state == u'FN':
    response = HttpResponse(status=410)
    response[getGoneResourceHeader()] = "event"
    return response

  joining_user = User.objects.get(pk=user_id)
  event_goer , created = EventGoer.objects.get_or_create(
    user=joining_user, event=event_to_join)
  
  #needed in case the user has logged out and is now logging back in
  if not created:
    event_goer.state=u'IE'
    event_goer.save()

  return HttpResponse("joined event", status=201)
Пример #3
0
def voteSong(event_id, playlist_id, user_id, voteWeigth):
  votingUser = User.objects.get(pk=user_id)
  entryToVote = get_object_or_404(ActivePlaylistEntry, pk=playlist_id)

  #Check to see if the song is still in the queue
  if entryToVote.state != u'QE':
    response = HttpResponse(status=410)
    response[getGoneResourceHeader()] = "song"
    return response

  #Check to see if a previous vote exists. If it does, change the weight
  #to the weight given in the arguments. If it doesn't, create a new one
  #with the specified weight
  try:
    previousVote = Vote.objects.get(
      user=votingUser, playlist_entry=entryToVote)
    previousVote.weight = voteWeigth
    previousVote.save()
  except ObjectDoesNotExist:
    Vote(user=votingUser, playlist_entry=entryToVote, weight=voteWeigth).save()
 
  return HttpResponse()
Пример #4
0
 def assert410Vote(self, playlist_id):
   response = self.doPost(
     '/udj/events/2/active_playlist/' + str(playlist_id) + '/users/5/downvote', {})
   self.assertEqual(response.status_code, 410)
   self.assertEqual(response[getGoneResourceHeader()], "song")
Пример #5
0
 def testJoinEndedEvent(self):
   response = self.doPut('/udj/events/1/users/5')
   self.assertEqual(response.status_code, 410)
   self.assertEqual(response[getGoneResourceHeader()], "event")
   shouldntBeThere = EventGoer.objects.filter(event__id=1, user__id=5)
   self.assertFalse(shouldntBeThere.exists())