Example #1
0
    def buildDoc(self, trans, elements):
        super(SubmitEventResource, self).buildDoc(trans, elements)

        self.station = self.getQueryValue("station",
                                          Typecasts.ValidStormObject(
                                              Station, self.store),
                                          defaultKey=None)
        self.eventClass = self.getQueryValue("eventClass",
                                             Typecasts.AllowBoth(
                                                 Typecasts.ValidStormObject(
                                                     EventClass, self.store),
                                                 Typecasts.EmptyString()),
                                             defaultKey=None)
        if self.eventClass == u"":
            self.eventClass = None
        self.startTime = self.getQueryValue("startTime",
                                            Typecasts.PriyomTimestamp(),
                                            defaultKey=TimeUtils.nowDate())
        self.endTime = self.getQueryValue("endTime",
                                          Typecasts.AllowBoth(
                                              Typecasts.PriyomTimestamp(),
                                              Typecasts.EmptyString()),
                                          defaultKey=None)
        if self.endTime == u"":
            self.endTime = None
        self.description = self.query.get("description", u"")
        if len(self.description) < 10:
            self.error = u"Description must be at least 10 characters long."

        self.link(u"/css/submit.css")
        self.setTitle(u"Submit event")

        submitted = False
        if "submit" in self.query and self.error is None:
            try:
                self.insert()
                submitted = True
            except SubmitParameterError:
                submitted = False

        if not submitted:
            self.SubElement(self.body,
                            u"pre").text = self.recursiveDict(self.query)
            if self.error is not None:
                self.SubElement(self.body, u"div", attrib={
                    u"class": u"error"
                }).text = self.error

            form = self.SubElement(self.body,
                                   u"form",
                                   name=u"logform",
                                   method=u"POST")

            self._eventInformationTree(self.section(form,
                                                    u"Event information"))
            self._descriptionTree(self.section(form, u"Description"))

            self.input(form, type=u"submit", name=u"submit", value=u"Submit")

            self._noteTree(self.section(self.body, u"Notes"))
Example #2
0
    def __init__(self, model):
        super(SubmitEventResource, self).__init__(model)
        self.allowedMethods = frozenset(("GET", "POST"))

        self.startTimeTypecast = Typecasts.PriyomTimestamp()
        self.endTimeTypecast = Typecasts.AllowBoth(Typecasts.PriyomTimestamp(),
                                                   Typecasts.EmptyString())
Example #3
0
    def __init__(self, model):
        super(SubmitLogResource, self).__init__(model)
        self.allowedMethods = frozenset(["GET", "POST"])

        self.stationValidator = Typecasts.ValidStormObject(Station, self.store)
        self.timestampValidator = Typecasts.PriyomTimestamp()
        self.durationValidator = float
        self.unicodeValidator = unicode

        self.broadcastValidator = Typecasts.AllowBoth(
            Typecasts.ValidStormObject(Broadcast, self.store),
            Typecasts.EmptyString())

        self.transmissionClassValidator = Typecasts.ValidStormObject(
            TransmissionClass, self.store)