def view(self, id): # We need to recheck auth in here so we can pass in the id if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_reviewer_role, h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.registration_status = h.config['app_conf'].get('registration_status') c.person = Person.find_by_id(id) return render('person/view.mako')
def _edit(self, id): """UPDATE PERSON""" # We need to recheck auth in here so we can pass in the id if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.person = Person.find_by_id(id) self.finish_edit(c.person) redirect_to(action='view', id=id)
def index(self): c.DAYS_OPEN = DAYS_OPEN c.open_date = lca_info.lca_info['date'] days_open = (datetime.date.today() - c.open_date.date()).days photo_db = PhotoCompEntry.read_db() photos = [ photo for days in photo_db.values() for entries in days for photo in entries if photo is not None and photo.day < days_open] c.no_photos = not photos day_filter = request.GET.get('day', 'All') if day_filter and day_filter != 'All': photos = [p for p in photos if str(p.day) == day_filter] person_filter = request.GET.get('person', 'All') if person_filter and person_filter != 'All': photos = [p for p in photos if str(p.person_id) == person_filter] submitted = request.GET.get('s', None) randomise = not submitted or 'randomise' in request.GET if randomise: random.shuffle(photos) else: photos.sort(key=lambda p: (p.day, p.person_id, p.entry_id)) person_map = {} for photo in photos: photo.write_scaled() person_map[photo.person_id] = None c.all_person = [] for person_id in person_map: person = Person.find_by_id(person_id) person_map[person_id] = person c.all_person.append(person) c.all_person.sort(key=lambda person: (person.firstname + " " + person.lastname).lower()) c.photos = photos def photo_title(photo): return "%s %s, %s entry %s, %s" % ( person_map[photo.person_id].firstname, person_map[photo.person_id].lastname, (c.open_date + datetime.timedelta(photo.day)).strftime('%A'), ENTRY_NAMES[photo.entry_id], photo.image_name,) c.photo_title = photo_title field_values = { 'day': day_filter, 'person': person_filter, } if randomise: field_values['randomise'] = '1' if submitted == 'Full Screen' and photos: html = render('/photocomp/index-fullscreen.mako') else: html = render('/photocomp/index.mako') return htmlfill.render(html, field_values)
def roles(self, id): c.person = Person.find_by_id(id) c.roles = Role.find_all() if not c.person.activated: h.flash( "NOTICE: This user hasn't confirmed their email address yet." " Please get them to visit" " %s" % h.full_url_for('person/activate'), category='warning') return render('person/roles.mako')
def _edit(self, id): """UPDATE PERSON""" # We need to recheck auth in here so we can pass in the id if not h.auth.authorized( h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.person = Person.find_by_id(id) self.finish_edit(c.person) redirect_to(action='view', id=id)
def view(self, id): # We need to recheck auth in here so we can pass in the id if not h.auth.authorized( h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_reviewer_role, h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.registration_status = h.config['app_conf'].get('registration_status') c.person = Person.find_by_id(id) return render('person/view.mako')
def edit(self, id): # We need to recheck auth in here so we can pass in the id if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.form = 'edit' c.person = Person.find_by_id(id) c.social_networks = SocialNetwork.find_all() c.person.fetch_social_networks() defaults = h.object_to_defaults(c.person, 'person') if not defaults['person.country']: defaults['person.country'] = 'AUSTRALIA' form = render('/person/edit.mako') return htmlfill.render(form, defaults)
def _offer(self,id): # We need to recheck auth in here so we can pass in the id if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_reviewer_role, h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.person = Person.find_by_id(id) c.offers = c.person.proposal_offers c.travel_assistance = reduce(lambda a, b: a or ('Travel' in b.status.name), c.offers, False) or False c.accommodation_assistance = reduce(lambda a, b: a or ('Accommodation' in b.status.name), c.offers, False) or False # What status are we moving all proposals to? if self.form_result['status'] == 'accept': c.status = ProposalStatus.find_by_name('Accepted') elif self.form_result['status'] == 'withdraw': c.status = ProposalStatus.find_by_name('Withdrawn') elif self.form_result['status'] == 'contact': c.status = ProposalStatus.find_by_name('Contact') else: c.status = None emails = [c.person.email_address] for offer in c.offers: offer.status = c.status if offer.type.notify_email and offer.type.notify_email not in emails: emails.append(offer.type.notify_email) if c.travel_assistance: if not c.person.travel: self.form_result['travel']['flight_details'] = '' travel = Travel(**self.form_result['travel']) meta.Session.add(travel) c.person.travel = travel else: for key in self.form_result['travel']: setattr(c.person.travel, key, self.form_result['travel'][key]) if c.status.name == 'Accepted': email(c.person.email_address, render('/person/offer_email.mako')) else: email(emails, render('/person/offer_email.mako')) # update the objects with the validated form data meta.Session.commit() return render('person/offer.mako')
def offer(self, id): # We need to recheck auth in here so we can pass in the id if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_user(id), h.auth.has_reviewer_role, h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.person = Person.find_by_id(id) c.offers = c.person.proposal_offers c.travel_assistance = reduce(lambda a, b: a or ('Travel' in b.status.name), c.offers, False) or False c.accommodation_assistance = reduce(lambda a, b: a or ('Accommodation' in b.status.name), c.offers, False) or False # Set initial form defaults defaults = { 'status': 'accept', } if c.person.travel: defaults.update(h.object_to_defaults(c.person.travel, 'travel')) form = render('person/offer.mako') return htmlfill.render(form, defaults)
def _roles(self, id): """ Lists and changes the person's roles. """ c.person = Person.find_by_id(id) c.roles = Role.find_all() role = self.form_result['role'] action = self.form_result['action'] role = Role.find_by_name(name=role) if action == 'Revoke' and role in c.person.roles: c.person.roles.remove(role) h.flash('Role ' + role.name + ' Revoked') elif action == 'Grant' and role not in c.person.roles: c.person.roles.append(role) h.flash('Role ' + role.name + ' Granted') else: h.flash("Nothing to do") meta.Session.commit() return render('person/roles.mako')
def reprint(self, id): c.person = Person.find_by_id(id) c.person.badge_printed = False meta.Session.commit() redirect_to(action='view', id=id)
def person(self, id): c.person = Person.find_by_id(id) return render('/fulfilment/person.mako')
def person(self, id): # TODO: This function breaks the URL model, id should be a fulfilment id c.person = Person.find_by_id(id) return render('/fulfilment/person.mako')
def person(self, id): # TODO: This function breaks the URL model, id should be a fulfilment id c.person = Person.find_by_id(id) return render("/fulfilment/person.mako")
def _to_python(self, value, state): person = Person.find_by_id(int(value), abort_404=False) if person is None: raise Invalid("Unknown person ID.", value, state) else: return person
def roles(self, id): c.person = Person.find_by_id(id) c.roles = Role.find_all() return render('person/roles.mako')
def _to_python(self, value, state): return Person.find_by_id(int(value))