Example #1
0
def view_user(request, user_id):
  user = User.objects.get(pk=user_id)
  username = user.username
  user_profile_id = user.get_profile().id

  own_events = Event.objects.filter(owner=user)
  participation_event_ids = Attendence.objects.filter(participant=user) \
                              .values_list('event_id')
  participation_events = Event.objects \
                           .filter(id__in=participation_event_ids)
  events = own_events | participation_events

  addFriendRequests = AddFriendRequest.objects \
                        .filter(requester=request.user, requestee=user)
  has_added = addFriendRequests.exists()
  
  #check whether has friendship
  is_friend = False
  if len(request.user.get_profile().friends \
       .filter(id=user_profile_id)) != 0:
    is_friend = True

  allAddFriendRequests = AddFriendRequest.objects.filter(requestee=user)

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

  return render(request, template, {
    'username': username,
    'events': events,
    "user_id": user_id,
    'is_self': (request.user.id == int(user_id)), 
    'is_friend': is_friend,
    'has_added': has_added,
    'allAddFriendRequests': allAddFriendRequests,
  }, content_type=content_type_from(request))  
Example #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))
Example #3
0
def register(request):
  if request.method == 'POST':
    form = CustomUserCreationForm(request.POST, request.FILES)
    if form.is_valid():
      new_user = form.save()
      return HttpResponseRedirect("/")
  else:
    form = CustomUserCreationForm()

  template = "eventdapp/register.%s" % ext_from(request)

  return render(request, template, {
    'form': form,
  }, content_type=content_type_from(request))
Example #4
0
def register(request):
    if request.method == 'POST':
        form = CustomUserCreationForm(request.POST, request.FILES)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("/")
    else:
        form = CustomUserCreationForm()

    template = "eventdapp/register.%s" % ext_from(request)

    return render(request,
                  template, {
                      'form': form,
                  },
                  content_type=content_type_from(request))
Example #5
0
def view_user(request, user_id):
    user = User.objects.get(pk=user_id)
    username = user.username
    user_profile_id = user.get_profile().id

    own_events = Event.objects.filter(owner=user)
    participation_event_ids = Attendence.objects.filter(participant=user) \
                                .values_list('event_id')
    participation_events = Event.objects \
                             .filter(id__in=participation_event_ids)
    events = own_events | participation_events

    addFriendRequests = AddFriendRequest.objects \
                          .filter(requester=request.user, requestee=user)
    has_added = addFriendRequests.exists()

    #check whether has friendship
    is_friend = False
    if len(request.user.get_profile().friends \
         .filter(id=user_profile_id)) != 0:
        is_friend = True

    allAddFriendRequests = AddFriendRequest.objects.filter(requestee=user)

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

    return render(request,
                  template, {
                      'username': username,
                      'events': events,
                      "user_id": user_id,
                      'is_self': (request.user.id == int(user_id)),
                      'is_friend': is_friend,
                      'has_added': has_added,
                      'allAddFriendRequests': allAddFriendRequests,
                  },
                  content_type=content_type_from(request))
Example #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))