def create_root_pdf(self, request, form): if form.submitted(request): request.app.root_pdf = request.app.pdf_class.from_agencies( agencies=self.roots, title=request.app.org.name, toc=True, exclude=request.app.org.hidden_people_fields, page_break_on_level=2) request.success(_("PDF created")) return redirect(request.link(self)) layout = AgencyCollectionLayout(self, request) layout.breadcrumbs.append(Link(_("Create PDF"), '#')) return { 'layout': layout, 'title': _("Create PDF"), 'helptext': _("Create a PDF of this agency and all its suborganizations. " "This may take a while."), 'form': form }
def create_agency_pdf(self, request, form): if form.submitted(request): self.pdf_file = request.app.pdf_class.from_agencies( agencies=[self], title=self.title, toc=False, exclude=request.app.org.hidden_people_fields, page_break_on_level=1) request.success(_("PDF created")) # FIXME: clear cache for redirect so that pdf link is updated return redirect(request.link(self)) layout = AgencyLayout(self, request) layout.breadcrumbs.append(Link(_("Create PDF"), '#')) return { 'layout': layout, 'title': _("Create PDF"), 'helptext': _("Create a PDF of this agency and all its suborganizations. " "This may take a while."), 'form': form }
def report_person_change(self, request, form): if form.submitted(request): session = request.session with session.no_autoflush: ticket = TicketCollection(session).open_ticket( handler_code='PER', handler_id=uuid4().hex, handler_data={ 'id': str(self.id), 'submitter_email': form.email.data, 'submitter_message': form.message.data }) TicketMessage.create(ticket, request, 'opened') ticket.create_snapshot(request) send_ticket_mail(request=request, template='mail_ticket_opened.pt', subject=_("Your ticket has been opened"), receivers=(form.email.data, ), ticket=ticket) request.success(_("Thank you for your submission!")) return redirect(request.link(ticket, 'status')) layout = ExtendedPersonLayout(self, request) layout.breadcrumbs.append(Link(_("Report change"), '#')) return { 'layout': layout, 'title': _("Report change"), 'lead': self.title, 'form': form }
def edit_attendee_limit(self, request, form): assert request.is_admin or self.username == request.current_username bookings = BookingCollection(request.session) bookings = bookings.for_username(self.username) if form.submitted(request): form.populate_obj(self) request.success(_("Your changes were saved")) return request.redirect(request.link(bookings)) elif not request.POST: form.process(obj=self) title = _("Booking Limit of ${name}", mapping={'name': self.name}) layout = BookingCollectionLayout(bookings, request, self.user) layout.breadcrumbs.append(Link(title, request.link(self))) return { 'form': form, 'layout': layout, 'title': title, }
def edit_attendee(self, request, form): # note: attendees are added in the views/occasion.py file assert request.is_admin or self.username == request.current_username bookings = BookingCollection(request.session) bookings = bookings.for_username(self.username) if form.submitted(request): form.populate_obj(self) request.success(_("Your changes were saved")) return request.redirect(request.link(bookings)) elif not request.POST: form.process(obj=self) title = _("Edit Attendee") layout = BookingCollectionLayout(bookings, request, self.user) layout.breadcrumbs.append(Link(title, request.link(self))) return { 'form': form, 'layout': layout, 'title': title, }
def view_people(self, request): request.include('common') request.include('chosen') request.include('people-select') if not request.is_logged_in: self.exclude_hidden = True letters = [ Link( text=letter.upper(), url=request.link( self.for_filter( letter=letter if (letter != self.letter) else None)), active=(letter == self.letter), ) for letter in self.used_letters ] Option = namedtuple('Option', ['title', 'value', 'selected']) agencies = [ Option( title=agency, value=request.link(self.for_filter(agency=agency)), selected=(agency == self.agency), ) for agency in self.used_agencies ] agencies.insert( 0, Option( title='', value=request.link(self.for_filter(agency=None)), selected=(self.agency is None), )) people = self.batch class AtoZPeople(AtoZ): def get_title(self, item): return item.title def get_items(self): return people def get_items_by_letter(self): items_by_letter = OrderedDict() for letter, items in groupby(self.get_items(), self.sortkey): items_by_letter[unidecode(letter)] = tuple(items) return items_by_letter people = AtoZPeople(request).get_items_by_letter() return { 'title': _("People"), 'layout': ExtendedPersonCollectionLayout(self, request), 'letters': letters, 'agencies': agencies, 'people': people.items() }
def add_root_agency(self, request, form): if form.submitted(request): agency = self.add_root(**form.get_useful_data()) request.success(_("Added a new agency")) return redirect(request.link(agency)) layout = AgencyCollectionLayout(self, request) layout.breadcrumbs.append(Link(_("New"), '#')) return {'layout': layout, 'title': _("New agency"), 'form': form}
def add_membership(self, request, form): if form.submitted(request): self.add_person(**form.get_useful_data()) request.success(_("Added a new membership")) return redirect(request.link(self)) layout = AgencyLayout(self, request) layout.breadcrumbs.append(Link(_("New membership"), '#')) return {'layout': layout, 'title': _("New membership"), 'form': form}
def get_links(notification): yield Link( text=_("Mailing"), url=request.link(notification, 'send') ) yield Link( text=_("Edit"), url=request.link(notification, 'edit') ) yield DeleteLink( text=_("Delete"), url=layout.csrf_protected_url(request.link(notification)), confirm=_('Do you really want to delete "${title}"?', mapping={ 'title': notification.subject, }), target='#{}'.format(notification.id.hex), yes_button_text=_("Delete Notification Template") )
def add_person(self, request, form): if form.submitted(request): person = self.add(**form.get_useful_data()) request.success(_("Added a new person")) return redirect(request.link(person)) layout = ExtendedPersonCollectionLayout(self, request) layout.breadcrumbs.append(Link(_("New"), '#')) layout.include_editor() return {'layout': layout, 'title': _("New person"), 'form': form}
def edit_membership(self, request, form): if form.submitted(request): form.populate_obj(self) request.success(_("Your changes were saved")) return redirect(request.link(self)) else: form.process(obj=self) layout = MembershipLayout(self, request) layout.breadcrumbs.append(Link(_("Edit"), '#')) return {'layout': layout, 'title': self.title, 'form': form}
def edit_agency(self, request, form): if form.submitted(request): form.update_model(self) request.success(_("Your changes were saved")) return redirect(request.link(self)) if not form.errors: form.apply_model(self) layout = AgencyLayout(self, request) layout.breadcrumbs.append(Link(_("Edit"), '#')) return {'layout': layout, 'title': self.title, 'form': form}
def view_hidden_agencies(self, request): session = request.session agencies = ExtendedAgencyCollection(session).query() agencies = agencies.filter( ExtendedAgency.meta['is_hidden_from_public'] == True ) agencies = agencies.order_by(None).order_by(ExtendedAgency.title) agencies = agencies.all() memberships = AgencyMembershipCollection(session).query( order_by='order_within_agency' ) memberships = memberships.filter( AgencyMembership.meta['is_hidden_from_public'] == True ) memberships = memberships.order_by(None).order_by(AgencyMembership.title) memberships = memberships.all() people = ExtendedPersonCollection(session).query() people = people.filter( ExtendedPerson.meta['is_hidden_from_public'] == True ) people = people.order_by(None).order_by( ExtendedPerson.last_name, ExtendedPerson.first_name ) people = people.all() layout = DefaultLayout(self, request) layout.breadcrumbs.append(Link(_("Hidden contents"), '#')) return { 'title': _("Hidden contents"), 'agencies': agencies, 'memberships': memberships, 'people': people, 'layout': layout }
def move_agency(self, request, form): if form.submitted(request): form.update_model(self) request.success(_("Agency moved")) return redirect(request.link(self)) if not form.errors: form.apply_model(self) layout = AgencyLayout(self, request) layout.breadcrumbs.append(Link(_("Move"), '#')) return { 'layout': layout, 'title': self.title, 'helptext': _("Moves the whole agency and all its people and suborganizations " "to the given destination."), 'form': form }