Skip to content

Commit dbd0608

Browse files
committed
re-added documentation, whoops for removing it :)
1 parent e3f7a7d commit dbd0608

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

events/views.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,33 @@
1111
from django.core.urlresolvers import reverse
1212

1313
def tonight(request, everyone=True):
14+
"""
15+
Renders a list of ``Event`` instances, which are selected mainly based on
16+
two factors:
17+
18+
The ``everyone`` parameter:
19+
If this is set to False, then we filter down the event list to be only
20+
those events that were created by or attended by one of the people who
21+
the user follows.
22+
23+
The user's authentication:
24+
If the user is authenticated, the user's events are separated from the
25+
other events.
26+
"""
1427
events = Event.objects.today().filter(latest=True)
1528
if request.user.is_authenticated():
1629
my_events = events.filter(creator=request.user) | events.filter(
1730
attendance__user=request.user)
1831
events = events.exclude(creator=request.user).exclude(
1932
attendance__user=request.user)
20-
following = request.user.following_set.all().values_list('to_user',
33+
following = request.user.following_set.all().values_list('to_user',
2134
flat=True)
2235
else:
2336
my_events = Event.objects.none()
2437
following = None
38+
if not everyone:
39+
events = events.filter(creator__in=following) | events.filter(
40+
attendance__user__in=following)
2541
events = events.order_by('-start_date', '-creation_date').distinct()
2642
context = {
2743
'events': events,
@@ -32,14 +48,23 @@ def tonight(request, everyone=True):
3248
return render_to_response(
3349
'events/tonight.html',
3450
context,
35-
context_instance = RequestContext(request),
51+
context_instance = RequestContext(request)
3652
)
3753

3854
def archive(request, everyone=True):
55+
"""
56+
Renders a list of ``Event`` instances, which are selected mainly based on
57+
one parameter:
58+
59+
``everyone``:
60+
If this is set to False, then we filter down the event list to be only
61+
those events that were created by or attended by one of the people who
62+
the user follows.
63+
"""
3964
events = Event.objects.filter(latest=True) | Event.objects.filter(
4065
attendance__user__isnull=False)
4166
if request.user.is_authenticated():
42-
following = list(request.user.following_set.all().values_list('to_user',
67+
following = list(request.user.following_set.all().values_list('to_user',
4368
flat=True))
4469
else:
4570
following = None
@@ -55,7 +80,7 @@ def archive(request, everyone=True):
5580
return render_to_response(
5681
'events/archive.html',
5782
context,
58-
context_instance = RequestContext(request),
83+
context_instance = RequestContext(request)
5984
)
6085

6186
def event(request, id):

0 commit comments

Comments
 (0)