Merge lp:~mhall119/loco-team-portal/bug-508471 into lp:loco-team-portal

Proposed by Michael Hall
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mhall119/loco-team-portal/bug-508471
Merge into: lp:loco-team-portal
Diff against target: 15 lines (+4/-1)
1 file modified
loco_directory/events/models.py (+4/-1)
To merge this branch: bzr merge lp:~mhall119/loco-team-portal/bug-508471
Reviewer Review Type Date Requested Status
Thomas Bechtold (community) Approve
Review via email: mp+17518@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Hall (mhall119) wrote :

The Attendee stuff was checking if the user had registered for an event, but it was failing if the user was AnonymousUser (aka, not logged in). This adds a check to user.is_authenticated(), and will return False on the team_event.is_attending(user) call if the user is not logged in.

Revision history for this message
Thomas Bechtold (toabctl) wrote :

Is it possible to use @login_required decorator for the method?

Revision history for this message
Michael Hall (mhall119) wrote :

Not in this case, because login_require will simply return an HttpResponseRedirect instead of calling the method, it's really only useful decorating views. I this case, I just want TeamEvent.is_attending(user) to return False if the user isn't logged in, not redirect them to the login page.

Revision history for this message
Thomas Bechtold (toabctl) wrote :

i'm not sure why the method is_attending() should be in the TeamEvent manager. I changed some code and uploaded another branch to lp:~thomasbechtold/loco-directory/fix-508471 . I'm not sure if this is more easy. Please check this.

44. By Michael Hall

Added extra validation to make sure an event's end date does not come before it's begin date

Revision history for this message
Thomas Bechtold (toabctl) wrote :

super!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loco_directory/events/models.py'
2--- loco_directory/events/models.py 2010-01-11 12:41:30 +0000
3+++ loco_directory/events/models.py 2010-01-16 17:57:11 +0000
4@@ -115,7 +115,10 @@
5 return ('team-event-detail', [str(self.id)])
6
7 def is_attending(self, user):
8- return self.attendee_set.filter(attendee=user).count() > 0
9+ if user.is_authenticated():
10+ return self.attendee_set.filter(attendee=user).count() > 0
11+ else:
12+ return False
13
14 #add manager
15 objects = TeamEventManager()

Subscribers

People subscribed via source and target branches