Project

General

Profile

« Previous | Next » 

Revision 52a1d10c

Added by Frédéric Péters about 12 years ago

Use new backoffice home brought by w.c.s. (#1673)

View differences:

extra/modules/backoffice.ptl
15 15
from qommon.form import *
16 16

  
17 17
class BackofficeRootDirectory(wcs.backoffice.root.RootDirectory):
18
    _q_exports = ['', 'home']
19

  
18 20
    def __init__(self):
19 21
        wcs.backoffice.root.RootDirectory.__init__(self)
20
        self._q_exports = wcs.backoffice.root.RootDirectory._q_exports
22

  
23
    items = [
24
        ('home', N_('Pending Forms')),
25
        ('/', N_('WCS Form Server'))]
21 26

  
22 27
    def _q_index [html] (self):
23
        from wcs.backoffice.menu import html_top
24
        html_top('/')
28
        return self.home()
29

  
30
    def home [html] (self):
25 31
        '<p>'
26 32
        _('Welcome on Au Quotidien back office interface')
27 33
        '</p>'
28

  
29
        user = get_request().user
30

  
31
        def append_form_entry(formdef):
32
            formdef_data_class = formdef.data_class()
33
            count_forms = formdef_data_class.count() - len(formdef_data_class.get_ids_with_indexed_value('status', 'draft'))
34
            if formdef.workflow:
35
                not_endpoint_status = formdef.workflow.get_not_endpoint_status()
36
                not_endpoint_status_ids = ['wf-%s' % x.id for x in not_endpoint_status]
37
            else:
38
                not_endpoint_status_ids = ['new', 'accepted']
39
            pending_forms = []
40
            for status in not_endpoint_status_ids:
41
                pending_forms.extend(formdef_data_class.get_ids_with_indexed_value(
42
                                        'status', status))
43
            if len(pending_forms) == 0:
44
                return
45
            l.append((formdef, len(pending_forms), count_forms))
46

  
47
        l = []
48
        if user:
49
            for formdef in FormDef.select(order_by='name', ignore_errors=True):
50
                if formdef.disabled:
51
                    continue
52
                if user.is_admin or formdef.receiver_id in (user.roles or []):
53
                    append_form_entry(formdef)
54

  
55
        if l:
56
            '<div class="bo-block">'
57
            '<h2>%s</h2>' % _('Forms in your care')
58
            '<ul>'
59
            cats = Category.select(order_by = 'name')
60
            one = False
61
            for c in cats:
62
                l2 = [x for x in l if x[0].category_id == c.id]
63
                if not l2:
64
                    continue
65
                '<li>%s</li>' % c.name
66
                '<ul>'
67
                for formdef, no_pending, no_total in l2:
68
                    '<li><a href="%s/">%s</a>' % (formdef.url_name, formdef.name)
69
                    _(': %(pending)s open on %(total)s') % {'pending': no_pending,
70
                                                            'total': no_total}
71
                    '</li>'
72
                    one = True
73
                '</ul>'
74

  
75
            l2 = [x for x in l if not x[0].category_id]
76
            if l2:
77
                if one:
78
                    '<li>%s</li>' % _('Misc')
79
                    '<ul>'
80
                for formdef, no_pending, no_total in l2:
81
                    '<li><a href="%s/">%s</a>' % (formdef.url_name, formdef.name)
82
                    _(': %(pending)s open on %(total)s') % {'pending': no_pending,
83
                                                            'total': no_total}
84
                    '</li>'
85
                if one:
86
                    '</ul>'
87
            '</ul>'
88
            '</div>'
34
        wcs.backoffice.root.RootDirectory.forms(self)
35
        from qommon.backoffice.menu import html_top
36
        html_top('home', _('Pending Forms'))
89 37

  
90 38
get_publisher_class().backoffice_directory_class = BackofficeRootDirectory
91 39

  

Also available in: Unified diff