Beispiel #1
0
 def subscribe(self, observer, ob):
     desc = ob.action_descriptor
     sub = model.Subscription(
         user=observer,
         ob_type=desc.ob_type,
         ob_refs=desc.ob_ids,
         subscribed=True)
     self.session.add(sub)
     return sub
Beispiel #2
0
 def subscription(self,
                  store=True,
                  repo_id='haiti',
                  person_id=None,
                  email='*****@*****.**',
                  language='en',
                  timestamp=datetime.datetime(2010, 1, 2)):
     subscription = model.Subscription(repo=repo_id,
                                       person_record_id=person_id,
                                       email=email,
                                       language=language,
                                       timestamp=timestamp)
     if store:
         subscription.put()
     return subscription
Beispiel #3
0
 def get(self, slug, action):
     feed = self.db.query(m.Feed).filter_by(slug = slug).first()
     subscription = self.db.query(m.Subscription).\
             filter_by(uid=self.current_user.id,fid=feed.id).first()
     if feed is None:
         raise tornado.web.HTTPError(404)
     if action.lower() == 'unsubscribe' and \
             subscription is not None:
         self.db.delete(subscription) 
         self.db_commit()
     elif action.lower() == 'subscribe' and \
             subscription is None:
         subscription = m.Subscription(uid=self.current_user.id, fid=feed.id)
         self.db.add(subscription)
         self.db_commit()
     else:
         raise tornado.web.HTTPError(404)
     self.redirect(self.get_argument('next', '/feed/'+feed.slug))