Exemplo n.º 1
0
 def getTransactionHistory(self, transactionCount, userMembership, lang):
     transactions_query_from = Transaction.gql("WHERE group = :1 AND fromMember = :2 ORDER BY date DESC", userMembership.group, userMembership)
     transactions_from = transactions_query_from.fetch(transactionCount)
     
     transactions_query_to = Transaction.gql("WHERE group = :1 AND toMember = :2 ORDER BY date DESC", userMembership.group, userMembership)
     transactions_to = transactions_query_to.fetch(transactionCount)
     
     transactions = transactions_from + transactions_to
     transactions.sort(cmp = compareTransactionsByDateDesc)
     
     transactions = transactions[0:transactionCount]
     
     messages = []
     for tr in transactions:
         if not tr.fromUser or not tr.toUser or not tr.creator:
             continue
         
         message = descriptionOfTransaction(tr, userMembership.user, lang)
         message = '%s %s' % (niceDate(tr.date, lang), message)
         messages.append({
             'message': message, 
             'benefical': transactionIsBenefical(tr, userMembership.user),
             'isRejectable': tr.isRejectable,
             'rejectUrl': '/reject?key=' + str(tr.key()) + '&h=' + tr.hash +'&cancel=1&trcount=' + str(transactionCount)
             })
          
     return messages
Exemplo n.º 2
0
 def get(self):
     key = self.request.get('key')
     hash = self.request.get('h')
     cancel = self.request.get('cancel')
     trCount = self.request.get('trcount')
     user = users.get_current_user()
     lang = getLanguage(self, user)
     
     # Check that all is ok
     tr = isValidTransaction(key, hash, user)
     if not tr:
         self.redirect('/')
         return
     
     template_values = {
         'key' : key,
         'h' : hash,
         'group' : tr.group,
         'showCancel' : cancel,
         'trCount' : trCount,
         'username' : user.nickname(),
         'transactionDescription': descriptionOfTransaction(tr, user, lang),
         'transactionIsBenefical': transactionIsBenefical(tr, user),
         'alreadyRejected': tr.isRejected,
         
         # i18n
         'YouAreRejecting': _('You are rejecting a transaction that says that', lang),
         'ButThatTransaccionWasAlreadyRejected': _('But that transaccion was already rejected.', lang),
         'Why': _('Please enter the reason why you are rejecting it', lang),
         'RejectTransaction': _('Reject transaction', lang),
         'Cancel': _('Cancel', lang)
     }
     
     addMasterKeys(template_values, lang)
                
     path = os.path.join(os.path.dirname(__file__), 'reject.html')
     self.response.out.write(template.render(path, template_values))
     return