Project

General

Profile

« Previous | Next » 

Revision 05a04465

Added by Frédéric Péters almost 14 years ago

Initial dashboard on backoffice

View differences:

extra/modules/backoffice.ptl
8 8
import wcs.backoffice.root
9 9
import wcs.root
10 10
from wcs.admin.menu import *
11
from wcs.categories import Category
12
from wcs.formdef import FormDef
11 13

  
12 14
from qommon import get_cfg
13 15
from qommon.form import *
......
24 26
        _('Welcome on Au Quotidien back office interface')
25 27
        '</p>'
26 28

  
29
        user = get_request().user
30

  
31
        def append_form_entry(formdef):
32
            all_forms = formdef.data_class().select()
33
            if formdef.workflow:
34
                not_endpoint_status = formdef.workflow.get_not_endpoint_status()
35
                not_endpoint_status_ids = ['wf-%s' % x.id for x in not_endpoint_status]
36
            else:
37
                not_endpoint_status_ids = ['new', 'accepted']
38
            pending_forms = [x for x in all_forms if x.status in not_endpoint_status_ids]
39
            l.append((formdef, len(pending_forms), len(all_forms)))
40

  
41
        l = []
42
        if user:
43
            for formdef in FormDef.select(order_by='name', ignore_errors=True):
44
                if formdef.disabled:
45
                    continue
46
                if user.is_admin or formdef.receiver_id in (user.roles or []):
47
                    append_form_entry(formdef)
48

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

  
68
            l2 = [x for x in l if not x[0].category_id]
69
            if l2:
70
                if one:
71
                    '<li>%s</li>' % _('Misc: ')
72
                    '<ul>'
73
                for formdef, no_pending, no_total in l2:
74
                    '<li><a href="%s/pending">%s</a>' % (formdef.url_name, formdef.name)
75
                    _(': %s open on %s') % (no_pending, no_total)
76
                    '</li>'
77
                if one:
78
                    '</ul>'
79
            '</ul>'
80
            '</div>'
81

  
27 82
get_publisher_class().backoffice_directory_class = BackofficeRootDirectory
28 83

  

Also available in: Unified diff