Esempio n. 1
0
 def upitem(self, session, item, reason=None):
     """ up a karma item with/without reason """
     item = item.lower()
     karma = session.query(Karma).filter(Karma.item==item).first()
     if not karma:
         karma = Karma(item, 0)
         session.add(karma)
     karma.value = karma.value + 1
     if reason:
         whykarma = WhyKarma(item, 'up', reason.strip())
         session.save(whykarma)
Esempio n. 2
0
 def down(self, session, item, reason=None):
     """ lower a karma item with/without reason """
     item = item.lower()
     s = create_session()
     karma = s.query(Karma).filter(Karma.item==item).first()
     if not karma:
         karma = Karma(item, 0)
         session.add(karma)
     karma.value = karma.value - 1
     if reason:
         whykarma = WhyKarma(item, 'down', reason.strip())
         session.save(whykarma)