Projet

Général

Profil

0002-toulouse_axel-order-endpoints-17729.patch

Lauréline Guérin, 30 avril 2020 16:26

Télécharger (9,04 ko)

Voir les différences:

Subject: [PATCH 2/3] toulouse_axel: order endpoints (#17729)

 passerelle/base/models.py                     |  2 +-
 passerelle/contrib/toulouse_axel/models.py    | 45 +++++++++++++++++++
 .../passerelle/manage/service_view.html       |  7 +++
 3 files changed, 53 insertions(+), 1 deletion(-)
passerelle/base/models.py
290 290
        status = self.get_availability_status()
291 291
        return (status and status.down())
292 292

  
293
    @endpoint(description=_('Check service availability'))
293
    @endpoint(description=_('Check service availability'), display_order=-1)
294 294
    def up(self, request, **kwargs):
295 295
        if self.down():
296 296
            raise APIError('service not available')
passerelle/contrib/toulouse_axel/models.py
52 52

  
53 53
    category = _('Business Process Connectors')
54 54

  
55
    _category_ordering = ['DUI', 'CAN-CLA', _('Invoices')]
56

  
55 57
    class Meta:
56 58
        verbose_name = _('Toulouse Axel')
57 59

  
......
60 62
        response.raise_for_status()
61 63

  
62 64
    @endpoint(
65
        display_order=1,
63 66
        description=_('Lock a resource'),
64 67
        perm='can_access',
65 68
        parameters={
......
73 76
        return {'key': key, 'locked': True, 'locker': lock.locker, 'lock_date': lock.lock_date}
74 77

  
75 78
    @endpoint(
79
        display_order=2,
76 80
        description=_('Unlock a resource'),
77 81
        perm='can_access',
78 82
        parameters={
......
87 91
            return {'key': key, 'locked': False}
88 92

  
89 93
    @endpoint(
94
        display_order=3,
90 95
        description=_('Get the lock status of a resource'),
91 96
        perm='can_access',
92 97
        parameters={
......
122 127
        return management_dates
123 128

  
124 129
    @endpoint(
130
        display_order=4,
125 131
        description=_("Get dates of the update management"),
126 132
        perm='can_access')
127 133
    def management_dates(self, request):
128 134
        return {'data': self.get_management_dates()}
129 135

  
130 136
    @endpoint(
137
        display_category='DUI',
138
        display_order=1,
131 139
        description=_('Create link between user and Toulouse Axel'),
132 140
        perm='can_access',
133 141
        parameters={
......
183 191
            raise APIError('Person not found', err_code='not-found')
184 192

  
185 193
    @endpoint(
194
        display_category='DUI',
195
        display_order=2,
186 196
        description=_('Delete link between user and Toulouse Axel'),
187 197
        methods=['post'],
188 198
        perm='can_access',
......
196 206
        return {'link': link_id, 'deleted': True, 'dui': link.dui}
197 207

  
198 208
    @endpoint(
209
        display_order=5,
199 210
        description=_("Get a referential"),
200 211
        perm='can_access',
201 212
        pattern=r'^(?P<code>[\w-]+)/?$',
......
260 271
        return family_data
261 272

  
262 273
    @endpoint(
274
        display_category='DUI',
275
        display_order=3,
263 276
        description=_("Get information about user's family"),
264 277
        perm='can_access',
265 278
        parameters={
......
271 284
        return {'data': family_data}
272 285

  
273 286
    @endpoint(
287
        display_category='DUI',
288
        display_order=4,
274 289
        description=_("Get information about children"),
275 290
        perm='can_access',
276 291
        parameters={
......
282 297
        return {'data': family_data.get('ENFANT', [])}
283 298

  
284 299
    @endpoint(
300
        display_category='DUI',
301
        display_order=5,
285 302
        description=_("Get information about a child"),
286 303
        perm='can_access',
287 304
        parameters={
......
299 316
        raise APIError('Child not found', err_code='not-found')
300 317

  
301 318
    @endpoint(
319
        display_category='DUI',
320
        display_order=6,
302 321
        description=_("Get information about a child's contacts"),
303 322
        perm='can_access',
304 323
        parameters={
......
475 494
            post_data.pop(flag)
476 495

  
477 496
    @endpoint(
497
        display_category='DUI',
498
        display_order=7,
478 499
        description=_("Update information about user's family"),
479 500
        perm='can_access',
480 501
        parameters={
......
581 602
                return invoice
582 603

  
583 604
    @endpoint(
605
        display_category=_('Invoices'),
606
        display_order=1,
584 607
        name='regie',
585 608
        perm='can_access',
586 609
        pattern=r'^(?P<regie_id>[\w-]+)/invoices/?$',
......
595 618
        return {'data': invoices_data}
596 619

  
597 620
    @endpoint(
621
        display_category=_('Invoices'),
622
        display_order=2,
598 623
        name='regie',
599 624
        perm='can_access',
600 625
        pattern=r'^(?P<regie_id>[\w-]+)/invoices/history/?$',
......
609 634
        return {'data': invoices_data}
610 635

  
611 636
    @endpoint(
637
        display_category=_('Invoices'),
638
        display_order=3,
612 639
        name='regie',
613 640
        perm='can_access',
614 641
        pattern=r'^(?P<regie_id>[\w-]+)/invoice/(?P<invoice_id>(historical-)?\w+-\d+)/?$',
......
629 656
        return {'data': invoice}
630 657

  
631 658
    @endpoint(
659
        display_category=_('Invoices'),
660
        display_order=4,
632 661
        name='regie',
633 662
        perm='can_access',
634 663
        pattern=r'^(?P<regie_id>[\w-]+)/invoice/(?P<invoice_id>(historical-)?\w+-\d+)/pdf/?$',
......
673 702
        return response
674 703

  
675 704
    @endpoint(
705
        display_category=_('Invoices'),
706
        display_order=5,
676 707
        name='regie',
677 708
        methods=['post'],
678 709
        perm='can_access',
......
847 878
        return child_activities
848 879

  
849 880
    @endpoint(
881
        display_category='CAN-CLA',
882
        display_order=1,
850 883
        description=_("Get information about CLAE activities of all children for the year"),
851 884
        perm='can_access',
852 885
        parameters={
......
868 901
        return {'data': list(children_activities.values())}
869 902

  
870 903
    @endpoint(
904
        display_category='CAN-CLA',
905
        display_order=2,
871 906
        description=_("Get the list of CLAE booked activities of a child, for a period"),
872 907
        perm='can_access',
873 908
        parameters={
......
926 961
        return {'data': result}
927 962

  
928 963
    @endpoint(
964
        display_category='CAN-CLA',
965
        display_order=3,
929 966
        description=_("Get possible days to book an activity of a child, for a period"),
930 967
        perm='can_access',
931 968
        parameters={
......
987 1024
        return {'data': activity_days}
988 1025

  
989 1026
    @endpoint(
1027
        display_category='CAN-CLA',
1028
        display_order=4,
990 1029
        description=_("Get annual possible days to book an activity of a child"),
991 1030
        perm='can_access',
992 1031
        parameters={
......
1025 1064
        return {'data': activity_days}
1026 1065

  
1027 1066
    @endpoint(
1067
        display_category='CAN-CLA',
1068
        display_order=5,
1028 1069
        description=_("Get booked days for an activity of a child, for a period"),
1029 1070
        perm='can_access',
1030 1071
        parameters={
......
1039 1080
        return {'data': [d['id'] for d in possible_days['data'] if d['prefill'] is True]}
1040 1081

  
1041 1082
    @endpoint(
1083
        display_category='CAN-CLA',
1084
        display_order=6,
1042 1085
        description=_("CLAE/Cantine booking"),
1043 1086
        perm='can_access',
1044 1087
        parameters={
......
1150 1193
        }
1151 1194

  
1152 1195
    @endpoint(
1196
        display_category='CAN-CLA',
1197
        display_order=7,
1153 1198
        description=_("CLAE/Cantine annual booking"),
1154 1199
        perm='can_access',
1155 1200
        parameters={
passerelle/templates/passerelle/manage/service_view.html
64 64
  {% block endpoints %}
65 65
    <ul class="endpoints">
66 66
    {% for endpoint in object.get_endpoints_infos %}
67
      {% ifchanged endpoint.display_category %}
68
      {% if endpoint.display_category %}
69
        </ul>
70
        <h4><span class="description">{{ endpoint.display_category }}</h4>
71
        <ul class="endpoints">
72
      {% endif %}
73
      {% endifchanged %}
67 74
      {% if endpoint.show %}
68 75
        {% include "passerelle/manage/endpoint.html" with endpoint=endpoint %}
69 76
      {% endif %}
70
-