Browse Source

reduce read/not read button size + mark content as read when you interact with it + mark read every stuff created by current user

Damien ACCORSI 9 years ago
parent
commit
fc2182810a

+ 31 - 3
tracim/tracim/lib/content.py View File

501
 
501
 
502
     def mark_read(self, content: Content,
502
     def mark_read(self, content: Content,
503
                   read_datetime: datetime=None,
503
                   read_datetime: datetime=None,
504
-                  do_flush=True) -> Content:
504
+                  do_flush: bool=True, recursive: bool=True) -> Content:
505
 
505
 
506
         assert self._user
506
         assert self._user
507
         assert content
507
         assert content
521
         for revision in viewed_revisions:
521
         for revision in viewed_revisions:
522
             revision.read_by[self._user] = read_datetime
522
             revision.read_by[self._user] = read_datetime
523
 
523
 
524
-        for child in content.get_valid_children():
525
-            self.mark_read(child, read_datetime=read_datetime, do_flush=False)
524
+        if recursive:
525
+            # mark read :
526
+            # - all children
527
+            # - parent stuff (if you mark a comment as read,
528
+            #                 then you have seen the parent)
529
+            # - parent comments
530
+            for child in content.get_valid_children():
531
+                self.mark_read(child, read_datetime=read_datetime,
532
+                               do_flush=False)
533
+
534
+            if ContentType.Comment == content.type:
535
+                self.mark_read(content.parent, read_datetime=read_datetime,
536
+                               do_flush=False, recursive=False)
537
+                for comment in content.parent.get_comments():
538
+                    if comment != content:
539
+                        self.mark_read(comment, read_datetime=read_datetime,
540
+                                       do_flush=False, recursive=False)
526
 
541
 
527
         if do_flush:
542
         if do_flush:
528
             self.flush()
543
             self.flush()
569
             content.revision_type = action_description
584
             content.revision_type = action_description
570
 
585
 
571
         if do_flush:
586
         if do_flush:
587
+            # INFO - 2015-09-03 - D.A.
588
+            # There are 2 flush because of the use
589
+            # of triggers for content creation
590
+            #
591
+            # (when creating a content, actually this is an insert of a new
592
+            # revision in content_revisions ; so the mark_read operation need
593
+            # to get full real data from database before to be prepared.
594
+
572
             DBSession.add(content)
595
             DBSession.add(content)
573
             DBSession.flush()
596
             DBSession.flush()
574
 
597
 
598
+            # TODO - 2015-09-03 - D.A. - Do not use triggers
599
+            # We should create a new ContentRevisionRO object instead of Content
600
+            # This would help managing view/not viewed status
601
+            self.mark_read(content, do_flush=True)
602
+
575
         if do_notify:
603
         if do_notify:
576
             self.do_notify(content)
604
             self.do_notify(content)
577
 
605
 

+ 2 - 0
tracim/tracim/public/assets/css/dashboard.css View File

360
 }
360
 }
361
 
361
 
362
 .panel-heading > h3 { font-size: 1.5em;}
362
 .panel-heading > h3 { font-size: 1.5em;}
363
+
364
+hr.t-toolbar-btn-group-separator { border-color: #CCC; border-style: dotted; }

+ 1 - 0
tracim/tracim/templates/file/toolbar.mak View File

6
     <div class="btn-group btn-group-vertical text-center">
6
     <div class="btn-group btn-group-vertical text-center">
7
         ${BUTTON.MARK_CONTENT_READ_OR_UNREAD(user, workspace, file)}
7
         ${BUTTON.MARK_CONTENT_READ_OR_UNREAD(user, workspace, file)}
8
     </div>
8
     </div>
9
+    <hr class="t-toolbar-btn-group-separator"/>
9
     <p></p>
10
     <p></p>
10
 
11
 
11
     <% download_url = tg.url('/workspaces/{}/folders/{}/files/{}/download?revision_id={}'.format(result.file.workspace.id, result.file.parent.id,result.file.id,result.file.selected_revision)) %>
12
     <% download_url = tg.url('/workspaces/{}/folders/{}/files/{}/download?revision_id={}'.format(result.file.workspace.id, result.file.parent.id,result.file.id,result.file.selected_revision)) %>

+ 1 - 0
tracim/tracim/templates/page/toolbar.mak View File

5
     <div class="btn-group btn-group-vertical">
5
     <div class="btn-group btn-group-vertical">
6
         ${BUTTON.MARK_CONTENT_READ_OR_UNREAD(user, workspace, page)}
6
         ${BUTTON.MARK_CONTENT_READ_OR_UNREAD(user, workspace, page)}
7
     </div>
7
     </div>
8
+    <hr class="t-toolbar-btn-group-separator"/>
8
     <p></p>
9
     <p></p>
9
 
10
 
10
     <% edit_disabled = ('', 'disabled')[page.selected_revision!='latest' or page.status.id[:6]=='closed'] %>
11
     <% edit_disabled = ('', 'disabled')[page.selected_revision!='latest' or page.status.id[:6]=='closed'] %>

+ 1 - 0
tracim/tracim/templates/thread/toolbar.mak View File

6
     <div class="btn-group btn-group-vertical">
6
     <div class="btn-group btn-group-vertical">
7
         ${BUTTON.MARK_CONTENT_READ_OR_UNREAD(user, workspace, thread)}
7
         ${BUTTON.MARK_CONTENT_READ_OR_UNREAD(user, workspace, thread)}
8
     </div>
8
     </div>
9
+    <hr class="t-toolbar-btn-group-separator"/>
9
     <p></p>
10
     <p></p>
10
 
11
 
11
     <% edit_disabled = ('', 'disabled')[thread.selected_revision!='latest' or thread.status.id[:6]=='closed'] %>
12
     <% edit_disabled = ('', 'disabled')[thread.selected_revision!='latest' or thread.status.id[:6]=='closed'] %>

+ 6 - 4
tracim/tracim/templates/widgets/button.mak View File

41
         if 'latest' != content.selected_revision:
41
         if 'latest' != content.selected_revision:
42
             disabled_or_not = 'disabled'
42
             disabled_or_not = 'disabled'
43
     %>
43
     %>
44
+
44
     % if content.is_new:
45
     % if content.is_new:
45
-       <a href="${content.urls.mark_read}" class="btn btn-success ${disabled_or_not}" style="text-align: center;">
46
-           <i class="fa fa-4x fa-fw fa-eye"></i><br/>
46
+       <a href="${content.urls.mark_read}" class="btn btn-success ${disabled_or_not}">
47
+           <i class="fa fa-fw fa-inverse fa-eye"></i>
47
            <span style="color: #FFF">${_('Mark read')}</span>
48
            <span style="color: #FFF">${_('Mark read')}</span>
48
        </a>
49
        </a>
49
     % else:
50
     % else:
50
-       <a href="${content.urls.mark_unread}" class="btn btn-default ${disabled_or_not}" style="text-align: center;">
51
-           <i class="fa fa-4x fa-fw fa-eye-slash tracim-less-visible"></i><br/>
51
+       <a href="${content.urls.mark_unread}" class="btn btn-default ${disabled_or_not}">
52
+           <i class="fa fa-fw fa-eye-slash t-less-visible"></i>
52
            <span class="tracim-less-visible">${_('Mark unread')}</span>
53
            <span class="tracim-less-visible">${_('Mark unread')}</span>
53
        </a>
54
        </a>
54
     % endif
55
     % endif
55
 </%def>
56
 </%def>
57
+