Mercurial > public > sg101
comparison gpp/gcalendar/models.py @ 456:5be072292e2d
Working on #220. Can't test locally, so committing in increments.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 01 Jul 2011 00:43:44 +0000 |
parents | d77e0dc772ad |
children | 9a4bffdf37c3 |
comparison
equal
deleted
inserted
replaced
455:e44dd53885dc | 456:5be072292e2d |
---|---|
1 """ | 1 """ |
2 Models for the gcalendar application. | 2 Models for the gcalendar application. |
3 | |
3 """ | 4 """ |
4 from django.db import models | 5 from django.db import models |
5 from django.db.models import Q | 6 from django.db.models import Q |
6 from django.contrib.auth.models import User | 7 from django.contrib.auth.models import User |
7 | 8 |
16 | 17 |
17 def get_query_set(self): | 18 def get_query_set(self): |
18 """Returns a queryset of events that have been approved to update | 19 """Returns a queryset of events that have been approved to update |
19 the Google calendar.""" | 20 the Google calendar.""" |
20 return super(PendingEventManager, self).get_query_set().filter( | 21 return super(PendingEventManager, self).get_query_set().filter( |
21 Q(status=Event.NEW_APRV) | \ | 22 Q(status=Event.NEW_APRV) | |
22 Q(status=Event.EDIT_APRV) | \ | 23 Q(status=Event.EDIT_APRV) | |
23 Q(status=Event.DEL_APRV) | 24 Q(status=Event.DEL_APRV) |
24 ) | 25 ) |
25 | 26 |
26 | 27 |
27 class Event(models.Model): | 28 class Event(models.Model): |
96 post_body = "%s\n\n[Link to event on Google Calendar](%s)" % ( | 97 post_body = "%s\n\n[Link to event on Google Calendar](%s)" % ( |
97 self.description, self.google_url) | 98 self.description, self.google_url) |
98 | 99 |
99 forums.tools.create_topic( | 100 forums.tools.create_topic( |
100 forum_slug=GIG_FORUM_SLUG, | 101 forum_slug=GIG_FORUM_SLUG, |
101 user=self.user, | 102 user=self.user, |
102 topic_name=topic_name, | 103 topic_name=topic_name, |
103 post_body=post_body) | 104 post_body=post_body) |
104 | 105 |
105 self.create_forum_thread = False | 106 self.create_forum_thread = False |
106 self.save() | 107 self.save() |
108 | |
109 | |
110 class AccessToken(models.Model): | |
111 """ | |
112 This model represents serialized OAuth access tokens for reading and | |
113 updating the Google Calendar. | |
114 | |
115 """ | |
116 auth_date = models.DateTimeField() | |
117 token = models.TextField() | |
118 | |
119 def __unicode__(self): | |
120 return u'Access token created on ' + unicode(self.auth_date) | |
121 |