Exemplo n.º 1
0
 def handleAdd(self, action):
     data, errors = self.extractData()
     # skip RequiredMissing errors
     errors = [e for e in errors if not self.isRequiredError(e.error)]
     if errors:
         self.status = self.formErrorsMessage
         # advoid required errors to be displayed then
         for name, widget in self.widgets.items():
             if widget.error and self.isRequiredError(widget.error.error):
                 self.widgets[name].error = None
         return
     obj = self.createAndAdd(data)
     if obj is not None:
         # mark only as finished if we get the new object
         self._finishedAdd = True
         IStatusMessage(self.request).addStatusMessage(_(u"Item created"), "info")
Exemplo n.º 2
0
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        # set program acceptancedate automatically
        if data.get("program1_accepted", None):
            data["program1_acceptancedate"] = datetime.now()
        if data.get("program2_accepted", None):
            data["program2_acceptancedate"] = datetime.now()
        if data.get("program3_accepted", None):
            data["program3_acceptancedate"] = datetime.now()
        self.applyChanges(data)

        # send email to user when saved as draft
        self.notifyUser(data["email"])

        IStatusMessage(self.request).addStatusMessage(_(u"Changes saved"), "info")
        self.request.response.redirect(self.context.absolute_url())
Exemplo n.º 3
0
def choiceVocabConstraint(value):
    """Check that the value selected is not blank
    """
    if value is None:
        raise Invalid(_(u"Selecting a First and Second Degree Program is required."))
    return True