class EventTypes(dd.Table): help_text = _("""The list of Event Types defined on this system. An EventType is a list of events which have certain things in common, especially they are displayed in the same colour in the calendar panel. """) required_roles = dd.required(OfficeStaff) model = 'cal.EventType' column_names = "name *" detail_layout = """ name event_label # description start_date id # type url_template username password #build_method #template email_template attach_to_email is_appointment all_rooms locks_user max_conflicting EventsByType """ insert_layout = dd.FormLayout(""" name event_label """, window_size=(60, 'auto'))
class About(EmptyTable): """Display information about this web site. This defines the window which opens via the menu command :menuselection:`Site --> About`. """ label = _("About") help_text = _("Show information about this site.") required_roles = set() hide_top_toolbar = True detail_layout = dd.FormLayout(""" about_html server_status """, window_size=(60, 20)) @dd.constant() def about_html(cls): body = [] body.append(settings.SITE.welcome_html()) #~ print "20121112 startup_time", settings.SITE.startup_time.date() def dtfmt(dt): if isinstance(dt, float): dt = datetime.datetime.fromtimestamp(dt) #~ raise ValueError("Expected float, go %r" % dt) return unicode(_("%(date)s at %(time)s")) % dict( date=dd.fdf(dt.date()), time=dt.time()) items = [] times = [] value = settings.SITE.startup_time label = _("Server uptime") body.append(E.p(unicode(label), ' : ', E.b(dtfmt(value)))) body.append(E.p(unicode(_("Source timestamps:")))) for src in ("lino", "lino_welfare", 'django', 'atelier'): label = src value = codetime('%s.*' % src) if value is not None: times.append((label, value)) def mycmp(a, b): return cmp(b[1], a[1]) times.sort(mycmp) for label, value in times: items.append(E.li(unicode(label), ' : ', E.b(dtfmt(value)))) body.append(E.ul(*items)) return E.div(*body, class_='htmlText') @dd.displayfield(_("Server status")) def server_status(cls, obj, ar): body = [] body.append( E.p( _("%s pending threads") % len(settings.SITE.kernel.pending_threads))) return E.div(*body, class_='htmlText')
class Links(dd.Table): model = 'humanlinks.Link' required_roles = dd.required(ContactsStaff) stay_in_grid = True detail_layout = dd.FormLayout(""" parent child type """, window_size=(40, 'auto'))
class Lists(dd.Table): required_roles = dd.required(dd.SiteStaff) model = 'lists.List' column_names = 'ref name list_type *' order_by = ['ref'] insert_layout = dd.FormLayout(""" ref list_type name remarks """, window_size=(60, 12)) detail_layout = dd.FormLayout(""" ref list_type id name remarks MembersByList """)
class Mails(dd.Table): #~ read_access = dd.required(user_level='manager') required_roles = dd.required(OfficeStaff) model = Mail column_names = "sent recipients subject * body" hidden_columns = 'body' order_by = ["sent"] detail_layout = dd.FormLayout(""" subject project date user sent #build_time id owner RecipientsByMail:50x5 AttachmentsByMail:20x5 uploads.UploadsByController:20x5 body:90x10 """) insert_layout = dd.FormLayout(""" project subject body """, window_size=(60, 20))
class TextFieldTemplates(dd.Table): model = TextFieldTemplate required_roles = dd.required(dd.SiteStaff, OfficeUser) insert_layout = dd.FormLayout(""" name user #team """, window_size=(60, 'auto')) detail_layout = """
class Comments(dd.Table): required_roles = dd.required(dd.SiteStaff) slave_grid_format = "summary" model = 'comments.Comment' insert_layout = dd.FormLayout(""" short_text """, window_size=(40, 10)) detail_layout = """
class Addresses(dd.Table): model = 'addresses.Address' required_roles = dd.required(dd.SiteStaff) column_names = ( "partner address_type:10 remark:10 " "address_column:30 primary data_source *") insert_layout = """ country city street street_no street_box address_type remark """ detail_layout = dd.FormLayout(""" country city zip_code addr1 street street_no street_box addr2 address_type remark data_source partner """, window_size=(60, 'auto'))
class Guests(dd.Table): "The default table for :class:`Guest`." help_text = _("""A guest is a partner invited to an event. """) model = 'cal.Guest' required_roles = dd.required(dd.SiteStaff, OfficeUser) column_names = 'partner role workflow_buttons remark event *' detail_layout = """ event partner role state remark workflow_buttons # outbox.MailsByController """ insert_layout = dd.FormLayout(""" event partner role """, window_size=(60, 'auto')) parameters = mixins.ObservedPeriod( user=dd.ForeignKey(settings.SITE.user_model, verbose_name=_("Responsible user"), blank=True, null=True, help_text=_("Only rows managed by this user.")), project=dd.ForeignKey(settings.SITE.project_model, blank=True, null=True), partner=dd.ForeignKey('contacts.Partner', blank=True, null=True), event_state=EventStates.field( blank=True, verbose_name=_("Event state"), help_text=_("Only rows having this event state.")), guest_state=GuestStates.field( blank=True, verbose_name=_("Guest state"), help_text=_("Only rows having this guest state.")), ) params_layout = """start_date end_date user event_state guest_state project partner""" @classmethod def get_request_queryset(self, ar): #~ logger.info("20121010 Clients.get_request_queryset %s",ar.param_values) qs = super(Guests, self).get_request_queryset(ar) if isinstance(qs, list): return qs if ar.param_values.user: qs = qs.filter(event__user=ar.param_values.user) if settings.SITE.project_model is not None and ar.param_values.project: qs = qs.filter(event__project=ar.param_values.project) if ar.param_values.event_state: qs = qs.filter(event__state=ar.param_values.event_state) if ar.param_values.guest_state: qs = qs.filter(state=ar.param_values.guest_state) if ar.param_values.partner: qs = qs.filter(partner=ar.param_values.partner) if ar.param_values.start_date: if ar.param_values.end_date: qs = qs.filter( event__start_date__gte=ar.param_values.start_date) else: qs = qs.filter(event__start_date=ar.param_values.start_date) if ar.param_values.end_date: qs = qs.filter(event__end_date__lte=ar.param_values.end_date) return qs @classmethod def get_title_tags(self, ar): for t in super(Guests, self).get_title_tags(ar): yield t if ar.param_values.start_date or ar.param_values.end_date: yield unicode( _("Dates %(min)s to %(max)s") % dict(min=ar.param_values.start_date or '...', max=ar.param_values.end_date or '...')) if ar.param_values.event_state: yield unicode(ar.param_values.event_state) if ar.param_values.partner: yield unicode(ar.param_values.partner) if ar.param_values.guest_state: yield unicode(ar.param_values.guest_state) # if ar.param_values.user: # yield unicode(ar.param_values.user) if settings.SITE.project_model is not None and ar.param_values.project: yield unicode(ar.param_values.project)
class Tasks(dd.Table): help_text = _("""A calendar task is something you need to do.""") model = 'cal.Task' required_roles = dd.required(OfficeStaff) column_names = 'start_date summary workflow_buttons *' order_by = ["start_date", "start_time"] detail_layout = """ start_date due_date id workflow_buttons summary user project #event_type owner created:20 modified:20 description #notes.NotesByTask """ insert_layout = dd.FormLayout(""" summary user project """, window_size=(50, 'auto')) params_panel_hidden = True parameters = mixins.ObservedPeriod( user=dd.ForeignKey(settings.SITE.user_model, verbose_name=_("Managed by"), blank=True, null=True, help_text=_("Only rows managed by this user.")), project=dd.ForeignKey(settings.SITE.project_model, blank=True, null=True), state=TaskStates.field(blank=True, help_text=_("Only rows having this state.")), ) params_layout = """ start_date end_date user state project """ @classmethod def get_request_queryset(self, ar): #~ logger.info("20121010 Clients.get_request_queryset %s",ar.param_values) qs = super(Tasks, self).get_request_queryset(ar) if ar.param_values.user: qs = qs.filter(user=ar.param_values.user) if settings.SITE.project_model is not None and ar.param_values.project: qs = qs.filter(project=ar.param_values.project) if ar.param_values.state: qs = qs.filter(state=ar.param_values.state) if ar.param_values.start_date: qs = qs.filter(start_date__gte=ar.param_values.start_date) if ar.param_values.end_date: qs = qs.filter(start_date__lte=ar.param_values.end_date) return qs @classmethod def get_title_tags(self, ar): for t in super(Tasks, self).get_title_tags(ar): yield t if ar.param_values.start_date or ar.param_values.end_date: yield unicode( _("Dates %(min)s to %(max)s") % dict(min=ar.param_values.start_date or '...', max=ar.param_values.end_date or '...')) if ar.param_values.state: yield unicode(ar.param_values.state) # if ar.param_values.user: # yield unicode(ar.param_values.user) if settings.SITE.project_model is not None and ar.param_values.project: yield unicode(ar.param_values.project) @classmethod def apply_cell_format(self, ar, row, col, recno, td): """ Enhance today by making background color a bit darker. """ if row.start_date == settings.SITE.today(): td.attrib.update(bgcolor="gold")