changeset 14 | 234db8f05928 |
parent 0 | 7c0001cacf8e |
child 24 | b5882159dea4 |
13:35afd52c902b | 14:234db8f05928 |
---|---|
40 from hypatia.query import And, Or, Eq, Any |
40 from hypatia.query import And, Or, Eq, Any |
41 from pyams_catalog.query import CatalogResultSet |
41 from pyams_catalog.query import CatalogResultSet |
42 from pyams_pagelet.pagelet import pagelet_config |
42 from pyams_pagelet.pagelet import pagelet_config |
43 from pyams_skin.container import ContainerView |
43 from pyams_skin.container import ContainerView |
44 from pyams_skin.page import DefaultPageHeaderAdapter |
44 from pyams_skin.page import DefaultPageHeaderAdapter |
45 from pyams_skin.table import BaseTable, I18nColumn, ActionColumn |
45 from pyams_skin.table import BaseTable, I18nColumn, NameColumn, JsActionColumn |
46 from pyams_skin.viewlet.menu import MenuItem |
46 from pyams_skin.viewlet.menu import MenuItem |
47 from pyams_template.template import template_config |
47 from pyams_template.template import template_config |
48 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter |
48 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter |
49 from pyams_utils.date import format_datetime, SH_DATETIME_FORMAT |
49 from pyams_utils.date import format_datetime, SH_DATETIME_FORMAT |
50 from pyams_utils.list import unique |
50 from pyams_utils.list import unique |
67 |
67 |
68 @implementer(ISharedToolDashboardTable) |
68 @implementer(ISharedToolDashboardTable) |
69 class BaseDashboardTable(BaseTable): |
69 class BaseDashboardTable(BaseTable): |
70 """Base dashboard table""" |
70 """Base dashboard table""" |
71 |
71 |
72 _title = '{0} contents' |
72 _single_title = '{0} content' |
73 _plural_title = '{0} contents' |
|
73 |
74 |
74 sortOn = None |
75 sortOn = None |
75 dt_sort_order = 'desc' |
76 dt_sort_order = 'desc' |
76 |
77 |
77 @property |
78 @property |
78 def title(self): |
79 def title(self): |
79 return self.request.localizer.translate(self._title).format(len(self.values)) |
80 translate = self.request.localizer.translate |
81 if len(self.values) < 2: |
|
82 return translate(self._single_title).format(len(self.values)) |
|
83 else: |
|
84 return translate(self._plural_title).format(len(self.values)) |
|
80 |
85 |
81 @property |
86 @property |
82 def data_attributes(self): |
87 def data_attributes(self): |
83 attributes = super(BaseDashboardTable, self).data_attributes |
88 attributes = super(BaseDashboardTable, self).data_attributes |
84 attributes['table'] = {'data-ams-datatable-sorting': "{0},{1}".format(len(self.columns)-1, |
89 attributes['table'] = {'data-ams-datatable-sorting': "{0},{1}".format(len(self.columns)-1, |
90 @cached_property |
95 @cached_property |
91 def values(self): |
96 def values(self): |
92 return tuple(super(BaseDashboardTable, self).values) |
97 return tuple(super(BaseDashboardTable, self).values) |
93 |
98 |
94 |
99 |
100 @adapter_config(name='name', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
|
101 class SharedToolDashboardNameColumn(NameColumn): |
|
102 """Shared tool dashboard name column""" |
|
103 |
|
104 _header = _("Title") |
|
105 |
|
106 |
|
95 @adapter_config(context=(IWfSharedContent, IPyAMSLayer, ISharedToolDashboardTable), provides=ITableElementName) |
107 @adapter_config(context=(IWfSharedContent, IPyAMSLayer, ISharedToolDashboardTable), provides=ITableElementName) |
96 class SharedToolDashboardContentNameAdapter(ContextRequestViewAdapter): |
108 class SharedToolDashboardContentNameAdapter(ContextRequestViewAdapter): |
97 """Shared tool dashboard content name adapter""" |
109 """Shared tool dashboard content name adapter""" |
98 |
110 |
99 @property |
111 @property |
100 def name(self): |
112 def name(self): |
101 return II18n(self.context).query_attribute('short_name', request=self.request) |
113 return II18n(self.context).query_attribute('title', request=self.request) |
102 |
114 |
103 |
115 |
104 @adapter_config(name='sequence', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
116 @adapter_config(name='sequence', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
105 class SharedToolDashboardSequenceColumn(I18nColumn, GetAttrColumn): |
117 class SharedToolDashboardSequenceColumn(I18nColumn, GetAttrColumn): |
106 """Shared tool dashboard sequence ID column""" |
118 """Shared tool dashboard sequence ID column""" |
123 |
135 |
124 def getValue(self, obj): |
136 def getValue(self, obj): |
125 return str(IWorkflowState(obj).version_id) |
137 return str(IWorkflowState(obj).version_id) |
126 |
138 |
127 |
139 |
128 @adapter_config(name='urgency', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
|
129 class SharedToolDashboardUrgencyColumn(ActionColumn): |
|
130 """Shared tool dashboard urgency column""" |
|
131 |
|
132 icon_class = 'fa fa-fw fa-exclamation-triangle txt-color-red' |
|
133 icon_hint = _("Urgent request !") |
|
134 |
|
135 url = '#' |
|
136 weight = 19 |
|
137 |
|
138 def renderCell(self, item): |
|
139 state = IWorkflowState(item) |
|
140 if not state.state_urgency: |
|
141 return '' |
|
142 else: |
|
143 return super(SharedToolDashboardUrgencyColumn, self).renderCell(item) |
|
144 |
|
145 def get_url(self, item): |
|
146 return self.url |
|
147 |
|
148 |
|
149 @adapter_config(name='status', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
140 @adapter_config(name='status', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
150 class SharedToolDashboardStatusColumn(I18nColumn, GetAttrColumn): |
141 class SharedToolDashboardStatusColumn(I18nColumn, GetAttrColumn): |
151 """Shared tool dashboard status column""" |
142 """Shared tool dashboard status column""" |
152 |
143 |
153 _header = _("Status") |
144 _header = _("Status") |
154 weight = 20 |
145 weight = 20 |
155 |
146 |
156 def getValue(self, obj): |
147 def getValue(self, obj): |
157 workflow = IWorkflow(obj) |
148 workflow = IWorkflow(obj) |
158 state = IWorkflowState(obj) |
149 state = IWorkflowState(obj) |
159 return self.request.localizer.translate(workflow.get_state_label(state.state)) |
150 result = self.request.localizer.translate(workflow.get_state_label(state.state)) |
151 if state.state_urgency: |
|
152 result += ' <i class="fa fa-fw fa-exclamation-triangle txt-color-red"></i>' |
|
153 return result |
|
160 |
154 |
161 |
155 |
162 @adapter_config(name='status_date', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
156 @adapter_config(name='status_date', context=(Interface, IPyAMSLayer, ISharedToolDashboardTable), provides=IColumn) |
163 class SharedToolDashboardStatusDateColumn(I18nColumn, GetAttrColumn): |
157 class SharedToolDashboardStatusDateColumn(I18nColumn, GetAttrColumn): |
164 """Shared tool dashboard status date column""" |
158 """Shared tool dashboard status date column""" |
261 |
255 |
262 @implementer(ISharedToolDashboardTable) |
256 @implementer(ISharedToolDashboardTable) |
263 class SharedToolDashboardManagerWaitingTable(BaseDashboardTable): |
257 class SharedToolDashboardManagerWaitingTable(BaseDashboardTable): |
264 """Shared tool dashboard waiting table""" |
258 """Shared tool dashboard waiting table""" |
265 |
259 |
266 _title = _("MANAGER - {0} content(s) waiting for your action") |
260 _single_title = _("MANAGER - {0} content waiting for your action") |
261 _plural_title = _("MANAGER - {0} contents waiting for your action") |
|
267 |
262 |
268 dt_sort_order = 'asc' |
263 dt_sort_order = 'asc' |
269 |
264 |
270 |
265 |
271 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolDashboardManagerWaitingTable), provides=IValues) |
266 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolDashboardManagerWaitingTable), provides=IValues) |
302 |
297 |
303 @implementer(ISharedToolDashboardTable) |
298 @implementer(ISharedToolDashboardTable) |
304 class SharedToolDashboardOwnerWaitingTable(BaseDashboardTable): |
299 class SharedToolDashboardOwnerWaitingTable(BaseDashboardTable): |
305 """Shared tool dashboard waiting owned contents table""" |
300 """Shared tool dashboard waiting owned contents table""" |
306 |
301 |
307 _title = _("CONTRIBUTOR - Your {0} content(s) waiting for action") |
302 _single_title = _("CONTRIBUTOR - {0} content waiting for action") |
303 _plural_title = _("CONTRIBUTOR - {0} contents waiting for action") |
|
308 |
304 |
309 dt_sort_order = 'asc' |
305 dt_sort_order = 'asc' |
310 |
306 |
311 |
307 |
312 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolDashboardOwnerWaitingTable), provides=IValues) |
308 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolDashboardOwnerWaitingTable), provides=IValues) |
332 |
328 |
333 @implementer(ISharedToolDashboardTable) |
329 @implementer(ISharedToolDashboardTable) |
334 class SharedToolDashboardOwnerModifiedTable(BaseDashboardTable): |
330 class SharedToolDashboardOwnerModifiedTable(BaseDashboardTable): |
335 """Shared tool dashboard owned modified contents table""" |
331 """Shared tool dashboard owned modified contents table""" |
336 |
332 |
337 _title = _("CONTRIBUTOR - Your last modified contents (limited to {0})") |
333 _single_title = _("CONTRIBUTOR - {0} modified content") |
334 |
|
335 @property |
|
336 def _plural_title(self): |
|
337 if len(self.values) <= 50: |
|
338 return _("CONTRIBUTOR - {0} modified contents") |
|
339 else: |
|
340 return _("CONTRIBUTOR - Last {0} modified contents") |
|
338 |
341 |
339 |
342 |
340 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolDashboardOwnerModifiedTable), provides=IValues) |
343 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolDashboardOwnerModifiedTable), provides=IValues) |
341 class SharedToolDashboardOwnerModifiedValues(ContextRequestViewAdapter): |
344 class SharedToolDashboardOwnerModifiedValues(ContextRequestViewAdapter): |
342 """Shared tool dashboard waiting owned contents values adapter""" |
345 """Shared tool dashboard waiting owned contents values adapter""" |
348 Or(Eq(catalog['role:owner'], self.request.principal.id), |
351 Or(Eq(catalog['role:owner'], self.request.principal.id), |
349 Eq(catalog['role:contributor'], self.request.principal.id))) |
352 Eq(catalog['role:contributor'], self.request.principal.id))) |
350 return unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state), |
353 return unique(map(lambda x: sorted(IWorkflowVersions(x).get_versions(IWorkflowState(x).state), |
351 key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0], |
354 key=lambda y: IZopeDublinCore(y).modified, reverse=True)[0], |
352 CatalogResultSet(CatalogQuery(catalog).query(params, |
355 CatalogResultSet(CatalogQuery(catalog).query(params, |
353 limit=IAdminProfile(self.request.principal).table_page_length, |
356 limit=50, |
354 sort_index='modified_date', |
357 sort_index='modified_date', |
355 reverse=True)))) |
358 reverse=True)))) |
356 |
359 |
357 |
360 |
358 # |
361 # |
370 icon_class = 'fa-user' |
373 icon_class = 'fa-user' |
371 url = '#' |
374 url = '#' |
372 |
375 |
373 |
376 |
374 # |
377 # |
378 # My favorites |
|
379 # Dashboard of favorites contents |
|
380 # |
|
381 |
|
382 @viewlet_config(name='my-favorites.menu', context=ISharedTool, layer=IAdminLayer, |
|
383 manager=IMyDashboardMenu, permission=VIEW_SYSTEM_PERMISSION, weight=3) |
|
384 class SharedToolFavoritesMenu(MenuItem): |
|
385 """Shared tool favorites dashboard menu""" |
|
386 |
|
387 label = _("My favorites") |
|
388 icon_class = None |
|
389 url = '#my-favorites.html' |
|
390 |
|
391 |
|
392 @implementer(ISharedToolDashboardTable) |
|
393 class SharedToolFavoritesTable(BaseDashboardTable): |
|
394 """Shared tool favorites table""" |
|
395 |
|
396 _single_title = _("CONTRIBUTOR - {0} favorite") |
|
397 _plural_title = _("CONTRIBUTOR - {0} favorites") |
|
398 |
|
399 |
|
400 @adapter_config(name='show-hide', context=(Interface, IPyAMSLayer, SharedToolFavoritesTable), |
|
401 provides=IColumn) |
|
402 class FavoritesColumnAddRemoveColumn(JsActionColumn): |
|
403 """Favorites column add/remove column""" |
|
404 |
|
405 cssClasses = {'th': 'action', |
|
406 'td': 'action switcher'} |
|
407 |
|
408 icon_class = 'fa fa-fw fa-star' |
|
409 icon_hint = _("Add/remove from favorites") |
|
410 |
|
411 url = 'PyAMS_content.profile.switchFavorite' |
|
412 |
|
413 weight = 1 |
|
414 |
|
415 def __init__(self, context, request, table): |
|
416 super(FavoritesColumnAddRemoveColumn, self).__init__(context, request, table) |
|
417 self.profile = IAdminProfile(request) |
|
418 |
|
419 def get_icon(self, item): |
|
420 oid = ISequentialIdInfo(item).hex_oid |
|
421 icon_class = 'fa fa-fw fa-star{0}'.format('' if oid in (self.profile.favorites or ()) else '-o') |
|
422 return '<i data-ams-plugins="pyams_content" ' \ |
|
423 'data-ams-plugin-pyams_content-src="/--static--/pyams_content/js/pyams_content{{MyAMS.devext}}.js" ' \ |
|
424 'data-ams-click-handler="PyAMS_content.profile.switchFavorite" data-ams-stop-propagation="true" ' \ |
|
425 'data-sequence-oid="{oid}" ' \ |
|
426 'class="{icon_class}"></i>'.format( |
|
427 oid=oid, |
|
428 title=self.request.localizer.translate(self.icon_hint), |
|
429 icon_class=icon_class) |
|
430 |
|
431 def get_url(self, item): |
|
432 return '' |
|
433 |
|
434 |
|
435 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolFavoritesTable), provides=IValues) |
|
436 class SharedToolFavoritesValues(ContextRequestViewAdapter): |
|
437 """Shared tool favorites values adapter""" |
|
438 |
|
439 @property |
|
440 def values(self): |
|
441 catalog = get_utility(ICatalog) |
|
442 profile = IAdminProfile(self.request.principal) |
|
443 params = And(Eq(catalog['content_type'], self.context.shared_content_type), |
|
444 Any(catalog['oid'], profile.favorites or ())) |
|
445 return unique(map(lambda x: IWorkflowVersions(x).get_last_versions()[0], |
|
446 CatalogResultSet(CatalogQuery(catalog).query(params, |
|
447 sort_index='modified_date', |
|
448 reverse=True)))) |
|
449 |
|
450 |
|
451 @pagelet_config(name='my-favorites.html', context=ISharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
|
452 @implementer(IInnerPage) |
|
453 class SharedToolFavoritesView(AdminView, ContainerView): |
|
454 """Shared tool favorites view""" |
|
455 |
|
456 table_class = SharedToolFavoritesTable |
|
457 |
|
458 |
|
459 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolFavoritesView), provides=IPageHeader) |
|
460 class SharedToolFavoritesHeaderAdapter(DefaultPageHeaderAdapter): |
|
461 """Shared tool favorites header adapter""" |
|
462 |
|
463 back_url = '#dashboard.html' |
|
464 icon_class = 'fa fa-fw fa-user' |
|
465 |
|
466 @property |
|
467 def title(self): |
|
468 return II18n(self.context).query_attribute('title', request=self.request) |
|
469 |
|
470 subtitle = _("Your favorites") |
|
471 |
|
472 |
|
473 # |
|
375 # My preparations |
474 # My preparations |
376 # Dashboard of owned and modified contents which can be updated |
475 # Dashboard of owned and modified contents which can be updated |
377 # |
476 # |
378 |
477 |
379 @viewlet_config(name='my-preparations.menu', context=ISharedTool, layer=IAdminLayer, |
478 @viewlet_config(name='my-preparations.menu', context=ISharedTool, layer=IAdminLayer, |
380 manager=IMyDashboardMenu, permission=VIEW_SYSTEM_PERMISSION, weight=5) |
479 manager=IMyDashboardMenu, permission=VIEW_SYSTEM_PERMISSION, weight=5) |
381 class SharedToolPreparationsMenu(MenuItem): |
480 class SharedToolPreparationsMenu(MenuItem): |
382 """Site root preparations dashboard menu""" |
481 """Shared tool preparations dashboard menu""" |
383 |
482 |
384 label = _("My preparations") |
483 label = _("My preparations") |
385 icon_class = None |
484 icon_class = None |
386 url = '#my-preparations.html' |
485 url = '#my-preparations.html' |
387 |
486 |
388 |
487 |
389 @implementer(ISharedToolDashboardTable) |
488 @implementer(ISharedToolDashboardTable) |
390 class SharedToolPreparationsTable(BaseDashboardTable): |
489 class SharedToolPreparationsTable(BaseDashboardTable): |
391 """Site root preparations table""" |
490 """Shared tool preparations table""" |
392 |
491 |
393 _title = _("CONTRIBUTOR - Your {0} prepared contents") |
492 _single_title = _("CONTRIBUTOR - {0} prepared content") |
493 _plural_title = _("CONTRIBUTOR - {0} prepared contents") |
|
394 |
494 |
395 |
495 |
396 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolPreparationsTable), provides=IValues) |
496 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolPreparationsTable), provides=IValues) |
397 class SharedToolPreparationsValues(ContextRequestViewAdapter): |
497 class SharedToolPreparationsValues(ContextRequestViewAdapter): |
398 """Site root preparations values adapter""" |
498 """Shared tool preparations values adapter""" |
399 |
499 |
400 @property |
500 @property |
401 def values(self): |
501 def values(self): |
402 catalog = get_utility(ICatalog) |
502 catalog = get_utility(ICatalog) |
403 workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow) |
503 workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow) |
404 params = And(Eq(catalog['content_type'], self.context.shared_content_type), |
504 params = And(Eq(catalog['content_type'], self.context.shared_content_type), |
405 Or(Eq(catalog['role:owner'], self.request.principal.id), |
505 Or(Eq(catalog['role:owner'], self.request.principal.id), |
406 Eq(catalog['role:contributor'], self.request.principal.id)), |
506 Eq(catalog['role:contributor'], self.request.principal.id)), |
407 Any(catalog['workflow_state'], workflow.update_states)) |
507 Eq(catalog['workflow_state'], workflow.initial_state)) |
408 return unique(CatalogResultSet(CatalogQuery(catalog).query(params, |
508 return unique(CatalogResultSet(CatalogQuery(catalog).query(params, |
409 sort_index='modified_date', |
509 sort_index='modified_date', |
410 reverse=True))) |
510 reverse=True))) |
411 |
511 |
412 |
512 |
413 @pagelet_config(name='my-preparations.html', context=ISharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
513 @pagelet_config(name='my-preparations.html', context=ISharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
414 @implementer(IInnerPage) |
514 @implementer(IInnerPage) |
415 class SharedToolPreparationsView(AdminView, ContainerView): |
515 class SharedToolPreparationsView(AdminView, ContainerView): |
416 """Site root preparations view""" |
516 """Shared tool preparations view""" |
417 |
517 |
418 table_class = SharedToolPreparationsTable |
518 table_class = SharedToolPreparationsTable |
419 |
519 |
420 |
520 |
421 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolPreparationsView), provides=IPageHeader) |
521 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolPreparationsView), provides=IPageHeader) |
422 class SharedToolPreparationsHeaderAdapter(DefaultPageHeaderAdapter): |
522 class SharedToolPreparationsHeaderAdapter(DefaultPageHeaderAdapter): |
423 """Site root preparations header adapter""" |
523 """Shared tool preparations header adapter""" |
424 |
524 |
425 back_url = '#dashboard.html' |
525 back_url = '#dashboard.html' |
426 icon_class = 'fa fa-fw fa-user' |
526 icon_class = 'fa fa-fw fa-user' |
427 |
527 |
428 @property |
528 @property |
429 def title(self): |
529 def title(self): |
430 return II18n(self.context).query_attribute('title', request=self.request) |
530 return II18n(self.context).query_attribute('title', request=self.request) |
431 |
531 |
432 subtitle = _("Your prepared contents") |
532 subtitle = _("Your prepared contents") |
533 |
|
534 |
|
535 # |
|
536 # My submissions |
|
537 # Dashboard of owned and modified contents which are waiting for manager action |
|
538 # |
|
539 |
|
540 @viewlet_config(name='my-submissions.menu', context=ISharedTool, layer=IAdminLayer, |
|
541 manager=IMyDashboardMenu, permission=VIEW_SYSTEM_PERMISSION, weight=7) |
|
542 class SharedToolSubmissionsMenu(MenuItem): |
|
543 """Shared tool submissions dashboard menu""" |
|
544 |
|
545 label = _("My submissions") |
|
546 icon_class = None |
|
547 url = '#my-submissions.html' |
|
548 |
|
549 |
|
550 @implementer(ISharedToolDashboardTable) |
|
551 class SharedToolSubmissionsTable(BaseDashboardTable): |
|
552 """Shared tool submissions table""" |
|
553 |
|
554 _single_title = _("CONTRIBUTOR - {0} submitted content") |
|
555 _plural_title = _("CONTRIBUTOR - {0} submitted contents") |
|
556 |
|
557 |
|
558 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolSubmissionsTable), provides=IValues) |
|
559 class SharedToolSubmissionsValues(ContextRequestViewAdapter): |
|
560 """Shared tool submissions values adapter""" |
|
561 |
|
562 @property |
|
563 def values(self): |
|
564 catalog = get_utility(ICatalog) |
|
565 workflow = get_utility(IWorkflow, name=self.context.shared_content_workflow) |
|
566 params = And(Eq(catalog['content_type'], self.context.shared_content_type), |
|
567 Or(Eq(catalog['role:owner'], self.request.principal.id), |
|
568 Eq(catalog['role:contributor'], self.request.principal.id)), |
|
569 Any(catalog['workflow_state'], workflow.waiting_states)) |
|
570 return unique(CatalogResultSet(CatalogQuery(catalog).query(params, |
|
571 sort_index='modified_date', |
|
572 reverse=True))) |
|
573 |
|
574 |
|
575 @pagelet_config(name='my-submissions.html', context=ISharedTool, layer=IPyAMSLayer, permission=VIEW_SYSTEM_PERMISSION) |
|
576 @implementer(IInnerPage) |
|
577 class SharedToolSubmissionsView(AdminView, ContainerView): |
|
578 """Shared tool submissions view""" |
|
579 |
|
580 table_class = SharedToolSubmissionsTable |
|
581 |
|
582 |
|
583 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolSubmissionsView), provides=IPageHeader) |
|
584 class SharedToolSubmissionsHeaderAdapter(DefaultPageHeaderAdapter): |
|
585 """Shared tool submissions header adapter""" |
|
586 |
|
587 back_url = '#dashboard.html' |
|
588 icon_class = 'fa fa-fw fa-user' |
|
589 |
|
590 @property |
|
591 def title(self): |
|
592 return II18n(self.context).query_attribute('title', request=self.request) |
|
593 |
|
594 subtitle = _("Your submitted contents") |
|
433 |
595 |
434 |
596 |
435 # |
597 # |
436 # My publications |
598 # My publications |
437 # Dashboard of owned and modified contents which are published |
599 # Dashboard of owned and modified contents which are published |
449 |
611 |
450 @implementer(ISharedToolDashboardTable) |
612 @implementer(ISharedToolDashboardTable) |
451 class SharedToolPublicationsTable(BaseDashboardTable): |
613 class SharedToolPublicationsTable(BaseDashboardTable): |
452 """Shared tool publications table""" |
614 """Shared tool publications table""" |
453 |
615 |
454 _title = _("CONTRIBUTOR - Your {0} published contents") |
616 _single_title = _("CONTRIBUTOR - {0} published content") |
617 _plural_title = _("CONTRIBUTOR - {0} published contents") |
|
455 |
618 |
456 |
619 |
457 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolPublicationsTable), provides=IValues) |
620 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolPublicationsTable), provides=IValues) |
458 class SharedToolPublicationsValues(ContextRequestViewAdapter): |
621 class SharedToolPublicationsValues(ContextRequestViewAdapter): |
459 """Shared tool publications values adapter""" |
622 """Shared tool publications values adapter""" |
510 |
673 |
511 @implementer(ISharedToolDashboardTable) |
674 @implementer(ISharedToolDashboardTable) |
512 class SharedToolRetiredContentsTable(BaseDashboardTable): |
675 class SharedToolRetiredContentsTable(BaseDashboardTable): |
513 """Shared tool retired contents table""" |
676 """Shared tool retired contents table""" |
514 |
677 |
515 _title = _("CONTRIBUTOR - Your {0} retired contents") |
678 _single_title = _("CONTRIBUTOR - {0} retired content") |
679 _plural_title = _("CONTRIBUTOR - {0} retired contents") |
|
516 |
680 |
517 |
681 |
518 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolRetiredContentsTable), provides=IValues) |
682 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolRetiredContentsTable), provides=IValues) |
519 class SharedToolRetiredContentsValues(ContextRequestViewAdapter): |
683 class SharedToolRetiredContentsValues(ContextRequestViewAdapter): |
520 """Shared tool retired contents values adapter""" |
684 """Shared tool retired contents values adapter""" |
572 |
736 |
573 @implementer(ISharedToolDashboardTable) |
737 @implementer(ISharedToolDashboardTable) |
574 class SharedToolArchivedContentsTable(BaseDashboardTable): |
738 class SharedToolArchivedContentsTable(BaseDashboardTable): |
575 """Shared tool archived contents table""" |
739 """Shared tool archived contents table""" |
576 |
740 |
577 _title = _("CONTRIBUTOR - Your {0} archived contents") |
741 _single_title = _("CONTRIBUTOR - {0} archived content") |
742 _plural_title = _("CONTRIBUTOR - {0} archived contents") |
|
578 |
743 |
579 |
744 |
580 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolArchivedContentsTable), provides=IValues) |
745 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolArchivedContentsTable), provides=IValues) |
581 class SharedToolArchivedContentsValues(ContextRequestViewAdapter): |
746 class SharedToolArchivedContentsValues(ContextRequestViewAdapter): |
582 """Shared tool archived contents values adapter""" |
747 """Shared tool archived contents values adapter""" |
656 |
821 |
657 @implementer(ISharedToolDashboardTable) |
822 @implementer(ISharedToolDashboardTable) |
658 class SharedToolAllPublicationsTable(BaseDashboardTable): |
823 class SharedToolAllPublicationsTable(BaseDashboardTable): |
659 """Shared tool published contents table""" |
824 """Shared tool published contents table""" |
660 |
825 |
661 _title = _("CONTRIBUTORS - Last published contents (in the limit of 50)") |
826 _single_title = _("CONTRIBUTORS - {0} published content") |
827 |
|
828 @property |
|
829 def _plural_title(self): |
|
830 if len(self.values) <= 50: |
|
831 return _("CONTRIBUTORS - Last {0} published contents") |
|
832 else: |
|
833 return _("CONTRIBUTORS - Last published contents (in the limit of 50)") |
|
662 |
834 |
663 |
835 |
664 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolAllPublicationsTable), provides=IValues) |
836 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolAllPublicationsTable), provides=IValues) |
665 class SharedToolAllPublicationsValues(ContextRequestViewAdapter): |
837 class SharedToolAllPublicationsValues(ContextRequestViewAdapter): |
666 """Shared tool published contents values adapter""" |
838 """Shared tool published contents values adapter""" |
717 |
889 |
718 @implementer(ISharedToolDashboardTable) |
890 @implementer(ISharedToolDashboardTable) |
719 class SharedToolAllUpdatesTable(BaseDashboardTable): |
891 class SharedToolAllUpdatesTable(BaseDashboardTable): |
720 """Shared tool updated contents table""" |
892 """Shared tool updated contents table""" |
721 |
893 |
722 _title = _("CONTRIBUTORS - Last updated contents (in the limit of 50)") |
894 _single_title = _("CONTRIBUTORS - {0} updated content") |
895 |
|
896 @property |
|
897 def _plural_title(self): |
|
898 if len(self.values) <= 50: |
|
899 return _("CONTRIBUTORS - Last {0} updated contents") |
|
900 else: |
|
901 return _("CONTRIBUTORS - Last updated contents (in the limit of 50)") |
|
723 |
902 |
724 |
903 |
725 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolAllUpdatesTable), provides=IValues) |
904 @adapter_config(context=(ISharedTool, IPyAMSLayer, SharedToolAllUpdatesTable), provides=IValues) |
726 class SharedToolAllUpdatesValues(ContextRequestViewAdapter): |
905 class SharedToolAllUpdatesValues(ContextRequestViewAdapter): |
727 """Shared tool updated contents values adapter""" |
906 """Shared tool updated contents values adapter""" |