def validate(self, action, data): errors = super(ReportView, self).validate(action, data) time_span = self.time_span(data) if IGroupSitting.providedBy(self.context): if not self.context.items: errors.append( interface.Invalid( _(u"The sitting has no scheduled items"))) else: start_date = data["date"] if "date" in data else \ datetime.datetime.today().date() end_date = self.get_end_date(start_date, time_span) try: ctx = ISchedulingContext(self.context) except: errors.append( interface.Invalid( _(u"You are trying to generate a report " "outside scheduling"))) sittings = ctx.get_sittings(start_date, end_date).values() if not sittings: errors.append( interface.Invalid( _(u"The period selected has no sittings"), "date")) parliament = queries.get_parliament_by_date_range( start_date, end_date) if parliament is None: errors.append( interface.Invalid( _(u"A parliament must be active in the period"), "date")) return errors
def validate(self, action, data): errors = super(ReportingView, self).validate(action, data) time_span = TIME_SPAN.daily if 'doc_type' in data: if data['doc_type'] == "Order of the day": time_span = TIME_SPAN.daily elif data['doc_type'] == "Proceedings of the day": time_span = TIME_SPAN.daily elif data['doc_type'] == "Weekly Business": time_span = TIME_SPAN.weekly elif data['doc_type'] == "Questions of the week": time_span = TIME_SPAN.weekly if 'date' in data: start_date = data['date'] else: start_date = self.date end_date = self.get_end_date(start_date, time_span) parliament = queries.get_parliament_by_date_range( self, start_date, end_date) session = queries.get_session_by_date_range(self, start_date, end_date) if parliament is None: errors.append( interface.Invalid( _(u"A parliament must be active in the period"), "date")) #elif session is None: # errors.append(interface.Invalid( # _(u"A session must be active in the period."), # "date")) return errors
def validate(self, action, data): errors = super(ReportView, self).validate(action, data) self.time_span = TIME_SPAN.daily if 'doc_type' in data: if data['doc_type'] == "Order of the day": self.time_span = TIME_SPAN.daily elif data['doc_type'] == "Proceedings of the day": self.time_span = TIME_SPAN.daily elif data['doc_type'] == "Weekly Business": self.time_span = TIME_SPAN.weekly elif data['doc_type'] == "Questions of the week": self.time_span = TIME_SPAN.weekly if IGroupSitting.providedBy(self.context): self.start_date = datetime.date( self.context.start_date.year, self.context.start_date.month, self.context.start_date.day) elif ISchedulingContext.providedBy(self.context): if 'date' in data: self.start_date = data['date'] else: self.start_date = datetime.today().date() self.end_date = self.get_end_date(self.start_date, self.time_span) parliament = queries.get_parliament_by_date_range(self, self.start_date, self.end_date) #session = queries.get_session_by_date_range(self, start_date, end_date) if parliament is None: errors.append(interface.Invalid( _(u"A parliament must be active in the period"), "date")) return errors
def validate(self, action, data): errors = super(ReportView, self).validate(action, data) time_span = self.time_span(data) if IGroupSitting.providedBy(self.context): if not self.context.items: errors.append(interface.Invalid( _(u"The sitting has no scheduled items"))) else: start_date = data["date"] if "date" in data else \ datetime.datetime.today().date() end_date = self.get_end_date(start_date, time_span) try: ctx = ISchedulingContext(self.context) except: errors.append(interface.Invalid( _(u"You are trying to generate a report " "outside scheduling") ) ) sittings = ctx.get_sittings(start_date, end_date).values() if not sittings: errors.append(interface.Invalid( _(u"The period selected has no sittings"), "date")) parliament = queries.get_parliament_by_date_range( start_date, end_date ) if parliament is None: errors.append(interface.Invalid( _(u"A parliament must be active in the period"), "date")) return errors
def validate(self, action, data): errors = super(ReportView, self).validate(action, data) self.time_span = TIME_SPAN.daily if 'doc_type' in data: if data['doc_type'] == "Order of the day": self.time_span = TIME_SPAN.daily elif data['doc_type'] == "Proceedings of the day": self.time_span = TIME_SPAN.daily elif data['doc_type'] == "Weekly Business": self.time_span = TIME_SPAN.weekly elif data['doc_type'] == "Questions of the week": self.time_span = TIME_SPAN.weekly if IGroupSitting.providedBy(self.context): self.start_date = datetime.date(self.context.start_date.year, self.context.start_date.month, self.context.start_date.day) elif ISchedulingContext.providedBy(self.context): if 'date' in data: self.start_date = data['date'] else: self.start_date = datetime.today().date() self.end_date = self.get_end_date(self.start_date, self.time_span) parliament = queries.get_parliament_by_date_range( self, self.start_date, self.end_date) #session = queries.get_session_by_date_range(self, start_date, end_date) if parliament is None: errors.append( interface.Invalid( _(u"A parliament must be active in the period"), "date")) return errors