コード例 #1
0
ファイル: views.py プロジェクト: NemesisSOAD/moneypot
    def remove_participant(self):
        '''
        This view removes an participant,
        it shows a warning if this participant already added expenses
        '''
        id_participant_to_remove = self.request.matchdict['id_participant_to_remove']
        participant = DBSession.query(Participant).get(id_participant_to_remove)

        #check if a participant was found
        if None == participant:
            self.request.session.flash(_(u"An error occured while searching the participant"))
            return self.redirect_to_pot

        #check if participant belongs to this pot
        # should not occur from ui, but only from "hackish" calls
        if participant.pot != self.pot:
            self.request.session.flash(_(u"This is not allowed!"))
            return self.redirect_to_pot
        #now everything should be fine

        # if participant has no expenses, delete him right away,
        # if he has expenses, wait for "submit" which means that the user confirmed his choice
        if not participant.expenses or 'submit' in self.request.POST:
            DBSession.delete(participant)
            self.request.session.flash(_(u'The participant {0} and all his expenses got deleted').format(participant.name), 'success')
            return self.redirect_to_pot
        else:
            question = {
                'title': _(u'Delete {0}?').format(participant.name),
                'message': _(u'The participant {0} already entered some expenses. These would be lost. Are you sure you want to proceed?').format(participant.name)
            }
            log.debug('return a question')
            return {'question': question, }
コード例 #2
0
ファイル: views.py プロジェクト: NemesisSOAD/moneypot
 def remove_expense(self):
     '''
     This view removes an expense
     '''
     id_to_remove = self.request.matchdict['id_to_remove']
     expense = DBSession.query(Expense).get(id_to_remove)
     DBSession.delete(expense)
     self.request.session.flash(_(u'The expense of {0} € got deleted').format(expense.amount), 'success')
     return self.redirect_to_pot
コード例 #3
0
ファイル: views.py プロジェクト: faucon/moneypot
 def remove_expense(self):
     """
     This view removes an expense
     """
     id_to_remove = self.request.matchdict["id_to_remove"]
     expense = DBSession.query(Expense).get(id_to_remove)
     DBSession.delete(expense)
     self.request.session.flash(_(u"The expense of {0} € got deleted").format(expense.amount), "success")
     return self.redirect_to_pot