def get(self): user = users.get_current_user() if user: lang = getLanguage(self, user) userMemberships = membershipsOfUser(user) userMemberships.sort(cmp = compareMembershipsByGroupNick) hasUserMemberships = len(userMemberships) > 0 if hasUserMemberships: group = userMemberships[0].group else: group = 0 debts = self.getDebts(user, userMemberships, lang) message = self.request.get('msg') hasMessage = len(message) > 0 model = { 'username': user.nickname(), 'signout_url': users.create_logout_url("/"), 'debts': debts, 'hasUserMemberships': hasUserMemberships, 'userMemberships': userMemberships, 'group': group, 'hasMessage': hasMessage, 'message': message, # i18n 'DontBelong': _("You don't belong to any group. You can create your own and invite your friends.", lang), 'Name': _('Name', lang), 'YouOweNobody': _('You owe nobody, and nobody owes you. Hurray!', lang), 'GoToGroup': _('Go to group', lang), 'SelectGroup': _('select group', lang), 'CreateGroup': _('Create Group', lang), } addMasterKeys(model, lang) path = os.path.join(os.path.dirname(__file__), 'dashboard.html') self.response.out.write(template.render(path, model)) else: lang = getDefaultLanguage(self) model = { 'loginurl': users.create_login_url("/"), # i18n 'introduction': _('introduction', lang), } addMasterKeys(model, lang) path = os.path.join(os.path.dirname(__file__), 'introduction.html') self.response.out.write(template.render(path, model))
def get(self): # Get user, group and user membership user = users.get_current_user() lang = getLanguage(self, user) group = Group.get(self.request.get("group")) groupMemberships = group.memberships userMembership = findMembershipForUser(groupMemberships, user) # Go to homepage if someone is trying to acces this group # without being a member if not userMembership: self.redirect('/') return # Get memberships of the current user userMemberships = membershipsOfUser(user) userMemberships.sort(cmp = compareMembershipsByGroupNick) hasUserMemberships = len(userMemberships) > 0 # Get user balance in this group [balanceSign, balance] = self.getBalance(userMembership, groupMemberships, lang) # Get user's transaction history for the "History" tab try: transactionCount = int(self.request.get('transactionCount', default_value=10)) transactions = self.getTransactionHistory(transactionCount, userMembership, lang) transactionCount = len(transactions) validationError = False validationMessage = '' except BaseException, e: transactionCount = 0 transactions = [] validationError = True validationMessage = '(' + _('This should be a number', lang) + ')'