[PATCH 8 of 8 sherpa] Start personal boards

Sylvain Thenault sylvain.thenault at logilab.fr
Tue Feb 28 17:08:22 CET 2017


# HG changeset patch
# User Sylvain Thénault <sylvain.thenault at logilab.fr>
# Date 1488297972 -3600
#      Tue Feb 28 17:06:12 2017 +0100
# Node ID b31919235a73a96a4b16bcc1ed6eac4321513c33
# Parent  409f9cbc02c5daa6409dcd6552e9061da52d795b
Start personal boards

which replace the anonymous index page.

Related to #13749115

diff --git a/cubicweb_sherpa/views/management.py b/cubicweb_sherpa/views/management.py
--- a/cubicweb_sherpa/views/management.py
+++ b/cubicweb_sherpa/views/management.py
@@ -16,16 +16,65 @@
 """Views related to edition management (dashboard, custom edition forms / display, etc).
 """
 
 from logilab.mtconverter import xml_escape
 
-from cubicweb.predicates import relation_possible, one_line_rset, non_final_entity
+from cubicweb import tags
+from cubicweb.predicates import (authenticated_user, non_final_entity,
+                                 one_line_rset, relation_possible)
+from cubicweb.view import EntityView
 from cubicweb.web import action, formwidgets
 from cubicweb.web.formfields import guess_field
 from cubicweb.web.views import actions, management
 
 from cubes.relationwidget.views import RelationFacetWidget
+from cubes.skos import views as skos
+
+from . import IndexView
+
+
+class AuthenticatedIndexView(IndexView):
+    __select__ = IndexView.__select__ & authenticated_user()
+    template_name = 'index_authenticated'
+
+    def build_context(self):
+        context = super(AuthenticatedIndexView, self).build_context()
+        for rql, key in [
+                ('Any X,XMD,XU,XT ORDERBY XMD DESC WHERE X is SEDAArchiveTransfer, '
+                 'X modification_date XMD, X created_by XU?, X title XT, '
+                 'X owned_by U, U eid %(u)s', 'profiles'),
+                ('Any X,XMD,XU,XUA ORDERBY XMD DESC WHERE X is SEDAArchiveUnit, '
+                 'X modification_date XMD, X created_by XU?, X user_annotation XUA, '
+                 'X owned_by U, U eid %(u)s', 'profiles'),
+                ('Any X,XMD,XU ORDERBY XMD DESC WHERE X is AuthorityRecord, '
+                 'X modification_date XMD, X created_by XU?,'
+                 'X owned_by U, U eid %(u)s', 'records'),
+        ]:
+            rset = self._cw.execute(rql, {'u': self._cw.user.eid})
+            if rset:
+                context['my_{}_html'.format(key)] = self._cw.view(
+                    'detailed-paginated-list', rset=rset)
+        return context
+
+
+class DetailedPaginatedListView(skos.PaginatedListView):
+    __regid__ = 'detailed-paginated-list'
+
+    def call(self, **kwargs):
+        super(DetailedPaginatedListView, self).call(subvid='detailed-item')
+
+
+class DetailedItemView(EntityView):
+    __regid__ = 'detailed-item'
+
+    def entity_call(self, entity):
+        self.w(tags.a(entity.dc_title(), href=entity.absolute_url()))
+        descr = [self._cw._('modified on {}').format(entity.printable_value('modification_date'))]
+        if entity.created_by:
+            user = entity.created_by[0]
+            descr.append(self._cw._('created by {}').format(user.name()))
+        self.w(tags.span(', '.join(descr), klass='text-muted'))
 
 
 class SherpaSecurityManagementView(management.SecurityManagementView):
     """Security view overriden to hide permissions definitions and using a
     RelationFacetWidget to edit owner.
diff --git a/cubicweb_sherpa/views/templates/index_authenticated.jinja2.html b/cubicweb_sherpa/views/templates/index_authenticated.jinja2.html
new file mode 100644
--- /dev/null
+++ b/cubicweb_sherpa/views/templates/index_authenticated.jinja2.html
@@ -0,0 +1,64 @@
+<div class="col-md-12" id="accueil">
+
+  <section>
+    <h2>Profils d'archivage</h2>
+    <div class="titleUnderline">
+      <span class="underline mr"></span><span class="losange"></span><span class="underline ml"></span>
+    </div>
+    <p>
+      Les profils d'archivage définissent la structure et le contenu attendu pour un bordereau de versement. Ils sont généralements associés à un flux d'archivage. <a href="{{ base_url}}/project">En savoir plus</a>
+    </p>
+    {% if my_profiles_html %}
+    <p>
+      Voici la liste des profils que vous avez rédigés ou sur lesquels vous avez le droit de modification :
+    </p>
+    {{ my_profiles_html|safe }}
+    {% endif %}
+    <div id="buttons-wrapper">
+      <a href="{{base_url}}/add/sedaarchivetransfer" class="btn btn-default">créer un nouveau profil</a>
+    </div>
+  </section>
+
+  <section>
+    <h2>Unités d'archive</h2>
+    <div class="titleUnderline">
+      <span class="underline mr"></span><span class="losange"></span><span class="underline ml"></span>
+    </div>
+    <p>
+      Les unités d'archives sont des morceaux de profils réutilisables ensuite dans les profils
+      d'archivage. <a href="{{ base_url}}/project">En savoir plus</a>
+    </p>
+    {% if my_units_html %}
+    <p>
+      Voici la liste des unités d'archives que vous avez
+      rédigées ou sur lesquelles vous avez le droit de modification :
+    </p>
+    {{ my_units_html|safe }}
+    {% endif %}
+    <div id="buttons-wrapper">
+      <a href="{{base_url}}/add/sedaarchiveunit?unit_type=unit_content" class="btn btn-default">créer une nouvelle unité d'archive</a>
+    </div>
+  </section>
+
+  <section>
+    <h2>Notices d'autorité</h2>
+    <div class="titleUnderline">
+      <span class="underline mr"></span><span class="losange"></span><span class="underline ml"></span>
+    </div>
+    <p>
+      Les notices d'autorité permettent de décrire les agents (personnes ou organisation)
+      intervenant dans la vie d'un document ou dans le processus d'archivage. <a href="{{ base_url}}/project">En savoir plus</a>
+    </p>
+    {% if my_records_html %}
+    <p>
+      Voici la liste des notices d'autorité que vous avez rédigées ou sur lesquelles vous avez le droit de
+      modification :
+    </p>
+    {{ my_records_html|safe }}
+    {% endif %}
+    <div id="buttons-wrapper">
+      <a href="{{base_url}}/add/authorityrecord" class="btn btn-default">créer une nouvelle notice d'autorité</a>
+    </div>
+  </section>
+
+</div>


More information about the saem-devel mailing list