def update(self): super(MainLayout, self).update() self.principal = principal = authenticated_userid(self.request) self.user = User.getByURI(principal) self.isanon = not self.user if principal and self.user is None: headers = forget(self.request) raise HTTPFound(location='/', headers=headers) if not self.isanon: self.membership = self.user.membership_label() self.policy = POLICIES.get(self.user.type, 0) if self.user.type in (1, 2): self.policy_id = self.user.type else: self.policy_id = 'free' price = config.PRICES.get(self.policy.id, 'free') if price == 'free': self.price = 'free' else: self.price = '$%s'%price self.removes = self.policy.removes - self.user.removes self.transfers = self.policy.transfers - self.user.transfers sites = len([s for s in self.user.sites if not s.removed]) self.sites = self.policy.sites - sites self.manager = self.user.email in ptah.PTAH_CONFIG.managers self.principal = self.user.email
def update(self): super(FrontendLayout, self).update() self.principal = principal = authenticated_userid(self.request) self.user = User.getByURI(principal) self.isanon = not self.user if principal and self.user is None: headers = forget(self.request) return HTTPFound(location='/', headers=headers) if not self.isanon: self.membership = self.user.membership_label() self.policy = POLICIES.get(self.user.type, 0) if self.user.type in (1, 2): self.policy_id = self.user.type else: self.policy_id = 'free' price = config.PRICES.get(self.policy.id, 'free') if price == 'free': self.price = 'free' else: self.price = '$%s'%price self.removes = self.policy.removes - self.user.removes self.transfers = self.policy.transfers - self.user.transfers sites = len([s for s in self.user.sites if not s.removed]) self.sites = self.policy.sites - sites MANAGE = ptah.get_settings(ptah.CFG_ID_PTAH, self.request.registry) self.manager = self.user.email in MANAGE['managers'] self.principal = self.user.email