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 _new(self): person_results = self.form_result['person'] proposal_results = self.form_result['proposal'] attachment_results = self.form_result['attachment'] proposal_results['status'] = ProposalStatus.find_by_name('Pending') c.proposal = Proposal(**proposal_results) meta.Session.add(c.proposal) if not h.signed_in_person(): c.person = model.Person(**person_results) meta.Session.add(c.person) email(c.person.email_address, render('/person/new_person_email.mako')) else: c.person = h.signed_in_person() for key in person_results: setattr(c.person, key, self.form_result['person'][key]) c.person.proposals.append(c.proposal) if attachment_results is not None: c.attachment = Attachment(**attachment_results) c.proposal.attachments.append(c.attachment) meta.Session.add(c.attachment) meta.Session.commit() email(c.person.email_address, render('proposal/thankyou_mini_email.mako')) h.flash("Proposal submitted!") return redirect_to(controller='proposal', action="index", id=None)
def _new(self): person_results = self.form_result['person'] proposal_results = self.form_result['proposal'] attachment_results = self.form_result['attachment'] proposal_results['status'] = ProposalStatus.find_by_name( 'Pending Review') c.proposal = Proposal(**proposal_results) meta.Session.add(c.proposal) if not h.signed_in_person(): c.person = model.Person(**person_results) meta.Session.add(c.person) email(c.person.email_address, render('/person/new_person_email.mako')) else: c.person = h.signed_in_person() for key in person_results: setattr(c.person, key, self.form_result['person'][key]) c.person.proposals.append(c.proposal) if attachment_results is not None: c.attachment = Attachment(**attachment_results) c.proposal.attachments.append(c.attachment) meta.Session.add(c.attachment) meta.Session.commit() email(c.person.email_address, render('proposal/thankyou_mini_email.mako')) h.flash("Proposal submitted!") return redirect_to(controller='proposal', action="index", id=None)
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 _approve(self): c.highlight = set() talks = self.form_result['talk'] statuses = self.form_result['status'] for talk, status in zip(talks, statuses): if status is not None: c.highlight.add(talk.id) talk.status = status meta.Session.commit() c.proposals = Proposal.find_all() c.statuses = ProposalStatus.find_all() return render("proposal/approve.mako")
def summary(self): c.proposal = {} for proposal_type in c.proposal_types: c.proposal[proposal_type] = Proposal.find_review_summary().filter( Proposal.type == proposal_type).filter( Proposal.status != ProposalStatus.find_by_name('Withdrawn') ).order_by('average').all() for aat in c.accommodation_assistance_types: stuff = Proposal.find_all_by_accommodation_assistance_type_id( aat.id) setattr(c, '%s_collection' % aat.name, stuff) for tat in c.travel_assistance_types: stuff = Proposal.find_all_by_travel_assistance_type_id(tat.id) setattr(c, '%s_collection' % tat.name, stuff) return render('proposal/summary.mako')
def summary(self): c.proposal = {} for proposal_type in c.proposal_types: c.proposal[proposal_type] = ( Proposal.find_review_summary() .filter(Proposal.type == proposal_type) .filter(Proposal.status != ProposalStatus.find_by_name("Withdrawn")) .order_by("average") .all() ) for aat in c.accommodation_assistance_types: stuff = Proposal.find_all_by_accommodation_assistance_type_id(aat.id) setattr(c, "%s_collection" % aat.name, stuff) for tat in c.travel_assistance_types: stuff = Proposal.find_all_by_travel_assistance_type_id(tat.id) setattr(c, "%s_collection" % tat.name, stuff) return render("proposal/summary.mako")
def _withdraw(self, id): if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_submitter(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.proposal = Proposal.find_by_id(id) status = ProposalStatus.find_by_name('Withdrawn') c.proposal.status = status meta.Session.commit() c.person = h.signed_in_person() # Make sure the organisers are notified of this c.email_address = h.lca_info['emails'][c.proposal.type.name.lower()] email(c.email_address, render('/proposal/withdraw_email.mako')) h.flash("Proposal withdrawn. The organisers have been notified.") return redirect_to(controller='proposal', action="index", id=None)
def _withdraw(self, id): if not h.auth.authorized(h.auth.Or(h.auth.is_same_zkpylons_submitter(id), h.auth.has_organiser_role)): # Raise a no_auth error h.auth.no_role() c.proposal = Proposal.find_by_id(id) status = ProposalStatus.find_by_name('Withdrawn') c.proposal.status = status meta.Session.commit() c.person = h.signed_in_person() # Make sure the organisers are notified of this c.email_address = c.proposal.type.notify_email.lower() email(c.email_address, render('/proposal/withdraw_email.mako')) h.flash("Proposal withdrawn. The organisers have been notified.") return redirect_to(controller='proposal', action="index", id=None)
def _new(self): if c.cfp_status == 'closed': if not h.auth.authorized( h.auth.Or(h.auth.has_organiser_role, h.auth.has_late_submitter_role)): return render("proposal/closed.mako") elif c.cfp_status == 'not_open': return render("proposal/not_open.mako") person_results = self.form_result['person'] proposal_results = self.form_result['proposal'] attachment_results = self.form_result['attachment'] proposal_results['status'] = ProposalStatus.find_by_name( 'Pending Review') c.proposal = Proposal(**proposal_results) c.proposal.abstract = self.clean_abstract(c.proposal.abstract) meta.Session.add(c.proposal) if not h.signed_in_person(): c.person = model.Person(**person_results) meta.Session.add(c.person) email(c.person.email_address, render('/person/new_person_email.mako')) else: c.person = h.signed_in_person() for key in person_results: setattr(c.person, key, self.form_result['person'][key]) c.person.proposals.append(c.proposal) if attachment_results is not None: attachment = Attachment(**attachment_results) c.proposal.attachments.append(attachment) meta.Session.add(attachment) meta.Session.commit() email(c.person.email_address, render('proposal/thankyou_email.mako')) h.flash("Proposal submitted!") return redirect_to(controller='proposal', action="index", id=None)
def _new(self): if c.cfp_status == 'closed': if not h.auth.authorized(h.auth.Or(h.auth.has_organiser_role, h.auth.has_late_submitter_role)): return render("proposal/closed.mako") elif c.cfp_status == 'not_open': return render("proposal/not_open.mako") person_results = self.form_result['person'] proposal_results = self.form_result['proposal'] attachment_results = self.form_result['attachment'] proposal_results['status'] = ProposalStatus.find_by_name('Pending Review') c.proposal = Proposal(**proposal_results) c.proposal.abstract = self.clean_abstract(c.proposal.abstract) meta.Session.add(c.proposal) if not h.signed_in_person(): # We don't want proposals to be submitted by folks who # aren't actually signed in. So, redirect them to the # sign-in page. h.flash("You need to be signed in to submit a proposal!") return redirect_to(controller="person", action="signin", id=None) else: c.person = h.signed_in_person() for key in person_results: setattr(c.person, key, self.form_result['person'][key]) c.person.proposals.append(c.proposal) if attachment_results is not None: attachment = Attachment(**attachment_results) c.proposal.attachments.append(attachment) meta.Session.add(attachment) meta.Session.commit() email(c.person.email_address, render('proposal/thankyou_email.mako')) h.flash("Proposal submitted!") return redirect_to(controller='proposal', action="index", id=None)
def _new(self): if c.cfp_status == 'closed': if not h.auth.authorized(h.auth.Or(h.auth.has_organiser_role, h.auth.has_late_submitter_role)): return render("proposal/closed.mako") elif c.cfp_status == 'not_open': return render("proposal/not_open.mako") person_results = self.form_result['person'] proposal_results = self.form_result['proposal'] attachment_results = self.form_result['attachment'] proposal_results['status'] = ProposalStatus.find_by_name('Pending') c.proposal = Proposal(**proposal_results) c.proposal.abstract = self.clean_abstract(c.proposal.abstract) meta.Session.add(c.proposal) if not h.signed_in_person(): c.person = model.Person(**person_results) meta.Session.add(c.person) email(c.person.email_address, render('/person/new_person_email.mako')) else: c.person = h.signed_in_person() for key in person_results: setattr(c.person, key, self.form_result['person'][key]) c.person.proposals.append(c.proposal) if attachment_results is not None: attachment = Attachment(**attachment_results) c.proposal.attachments.append(attachment) meta.Session.add(attachment) meta.Session.commit() email(c.person.email_address, render('proposal/thankyou_email.mako')) h.flash("Proposal submitted!") return redirect_to(controller='proposal', action="index", id=None)
def approve(self): c.highlight = set() c.proposals = Proposal.find_all() c.statuses = ProposalStatus.find_all() return render("proposal/approve.mako")
def _to_python(self, value, state): return ProposalStatus.find_by_id(int(value))