Exemplo n.º 1
0
    def get_users_groups_slots(user):
        groups = Group.get_is_member_list(user)
        events = None
        slots = None
        for group in groups:
            if (events == None):
                events = Event.objects.filter(parentGroup=group)
            else:
                groups_events = Event.objects.filter(parentGroup=group)
                events = events | groups_events

            if (slots == None):
                slots = Slot.objects.filter(parentGroup=group)
            else:
                groups_slots = Slot.objects.filter(parentGroup=group)
                slots = slots | groups_slots

        if events == None:
            return None

        for event in events:
            if (slots == None):
                slots = Slot.objects.filter(parentEvent=event)
            else:
                events_slots = Slot.objects.filter(parentEvent=event)
                slots = slots | events_slots

        if (slots == None):
            return slots
        return slots.order_by(
            'start'
        )  # Slot.objects.filter(Q(parentEvent.parentGroup.get_is_member(user))).objects.order_by('start')
Exemplo n.º 2
0
def filterByGroup(request, group_id):
    group = Group.objects.get(id=group_id)
    if (request.user.is_authenticated() and group.get_is_member(request.user)):
        groups = Group.get_is_member_list(request.user)
        feed_entries = Feed_Entry.objects.filter(group=group).order_by('-datetime') #feed entries are sorted from most recent to least recent
        return render(request, 'feed/feed.html', {'feed_entries':feed_entries, 'groups':groups})
    else:
        if (not(group.get_is_member(request.user))):
            return redirect('feed')
        else:
            return redirect('login')
Exemplo n.º 3
0
    def get_users_groups_events(user):
        groups = Group.get_is_member_list(user)
        events = None
        for group in groups:
            if (events == None):
                events = Event.objects.filter(parentGroup=group)
            else:
                groups_events = Event.objects.filter(parentGroup=group)
                events = events.union(groups_events)

        if (events == None):
            return events
        return events.order_by('start')
Exemplo n.º 4
0
def other_profile(request, user_id):
    user = User.objects.get(id=user_id)
    if (user != request.user):
        profile = Profile.objects.get(user=user)
        groups = Group.get_is_member_list(user)
        feed_entries = Feed_Entry.objects.filter(
            user=request.user).order_by('-datetime')[:10]
        return render(
            request, 'accounts/profile.html', {
                'user': user,
                'profile': profile,
                'feed_entries': feed_entries,
                'this_user': False,
                'groups': groups
            })
    else:
        return redirect('/accounts/profile')
Exemplo n.º 5
0
def profile(request):
    if request.user.is_authenticated():
        # This line breaks the code: "'int' is not iterable"
        user = request.user
        profile = user.profile
        groups = Group.get_is_member_list(request.user)

        feed_entries = Feed_Entry.objects.filter(
            user=user).order_by('-datetime')[:10]
        return render(
            request, "accounts/profile.html", {
                'user': user,
                'profile': profile,
                'feed_entries': feed_entries,
                'this_user': True,
                'groups': groups
            })
    else:
        return redirect('/login')
Exemplo n.º 6
0
def feed(request):
    if request.user.is_authenticated():
        groups = Group.get_is_member_list(request.user)
        feed_entries = None
        for group in groups:
            if (feed_entries==None):
                feed_entries=Feed_Entry.objects.filter(group=group).filter(private=False)
            elif (feed_entries==None and group.get_is_organzer):
                feed_entries=Feed_Entry.objects.filter(group=group)
            elif group.get_is_organzer:
                groups_entrys = Feed_Entry.objects.filter(group=group)
                feed_entries=feed_entries.union(groups_entrys)
            else:
                groups_entrys = Feed_Entry.objects.filter(group=group).filter(private=False)
                feed_entries=feed_entries.union(groups_entrys)

        if (not(feed_entries==None)):
            feed_entries = feed_entries.order_by('-datetime')
        return render(request, 'feed/feed.html', {'feed_entries': feed_entries, 'groups':groups})
    else:
        return redirect('login')