Browse Source

Merge branch 'master' of https://github.com/tracim/tracim into dev/_/185/button_to_read_all

Alexis CLEMENT 8 years ago
parent
commit
f7f8b955c3

+ 1 - 1
install/requirements.txt View File

@@ -47,7 +47,7 @@ speaklater==1.3
47 47
 sprox==0.9.4
48 48
 stevedore==1.1.0
49 49
 tg.devtools==2.3.7
50
-git+https://github.com/algoo/tgapp-resetpassword.git
50
+git+https://github.com/gasbasd/tgapp-resetpassword.git
51 51
 tgext.admin==0.6.4
52 52
 tgext.crud==0.7.3
53 53
 tgext.pluggable==0.6.2

+ 0 - 4
tracim/tracim/config/app_cfg.py View File

@@ -217,10 +217,6 @@ class CFG(object):
217 217
                 'email.notification.from.default_label.'
218 218
             )
219 219
 
220
-        self.AUTO_GENERATED_PASSWORD_LENGTH = tg.config.get(
221
-            'tracim.password.length'
222
-        )
223
-
224 220
         self.EMAIL_NOTIFICATION_FROM_EMAIL = \
225 221
             tg.config.get('email.notification.from.email')
226 222
         self.EMAIL_NOTIFICATION_FROM_DEFAULT_LABEL = \

+ 14 - 10
tracim/tracim/controllers/admin/user.py View File

@@ -275,6 +275,11 @@ class UserRestController(TIMRestController):
275 275
     profile = UserProfileAdminRestController()
276 276
     workspaces = UserWorkspaceRestController()
277 277
 
278
+    PASSWORD_LENGTH = 12
279
+    PASSWORD_CHARACTERS = '0123456789' \
280
+                          'abcdefghijklmonpqrstuvwxyz' \
281
+                          'ABCDEFGHIJKLMONPQRSTUVWXYZ'
282
+
278 283
     @classmethod
279 284
     def current_item_id_key_in_context(cls):
280 285
         return 'user_id'
@@ -354,21 +359,20 @@ class UserRestController(TIMRestController):
354 359
         tg.redirect(self.url())
355 360
 
356 361
     @classmethod
357
-    def generate_password(cls):
358
-        # Characters available to generate a password
359
-        characters = '0123456789' \
360
-                     'abcdefghijklmonpqrstuvwxyz' \
361
-                     'ABCDEFGHIJKLMONPQRSTUVWXYZ'
362
+    def generate_password(
363
+            cls,
364
+            password_length = PASSWORD_LENGTH,
365
+            password_chars = PASSWORD_CHARACTERS
366
+            ):
362 367
 
363 368
         # character list that will be contained into the password
364
-        list_char = []
369
+        char_list = []
365 370
 
366
-        pass_length = int(CFG.get_instance().AUTO_GENERATED_PASSWORD_LENGTH)
367
-        for j in range(0, pass_length):
371
+        for j in range(0, password_length):
368 372
             # This puts a random char from the list above inside
369 373
             # the list of chars and then merges them into a String
370
-            list_char.append(random.choice(characters))
371
-            password = ''.join(list_char)
374
+            char_list.append(random.choice(password_chars))
375
+            password = ''.join(char_list)
372 376
         return password
373 377
 
374 378
     @tg.expose('tracim.templates.admin.user_getone')

+ 8 - 0
tracim/tracim/lib/helpers.py View File

@@ -82,6 +82,14 @@ def time(datetime_object):
82 82
     current_locale = tg.i18n.get_lang()[0]
83 83
     return format_time(datetime_object, locale=current_locale)
84 84
 
85
+def update_date(datetime_object):
86
+    current_locale = tg.i18n.get_lang()[0]
87
+    return format_date(datetime_object, locale=current_locale)
88
+
89
+def update_time(datetime_object):
90
+    current_locale = tg.i18n.get_lang()[0]
91
+    return format_time(datetime_object, locale=current_locale)
92
+
85 93
 def format_short(datetime_object):
86 94
     return datetime_object.strftime(format = plag.Globals.SHORT_DATE_FORMAT.__str__())
87 95
 

+ 8 - 0
tracim/tracim/model/data.py View File

@@ -1039,6 +1039,14 @@ class Content(DeclarativeBase):
1039 1039
         return self.get_current_revision()
1040 1040
 
1041 1041
     @property
1042
+    def first_revision(self) -> ContentRevisionRO:
1043
+        return self.revisions[0]  # FIXME
1044
+
1045
+    @property
1046
+    def last_revision(self) -> ContentRevisionRO:
1047
+        return self.revisions[-1]
1048
+
1049
+    @property
1042 1050
     def is_editable(self) -> bool:
1043 1051
         return not self.is_archived and not self.is_deleted
1044 1052
 

+ 11 - 3
tracim/tracim/model/serializers.py View File

@@ -388,12 +388,14 @@ def serialize_node_for_page(content: Content, context: Context):
388 388
             is_new=content.has_new_information_for(context.get_user()),
389 389
             content=data_container.description,
390 390
             created=data_container.created,
391
+            updated=content.last_revision.updated,
391 392
             label=data_container.label,
392 393
             icon=ContentType.get_icon(content.type),
393
-            owner=context.toDict(data_container.owner),
394
+            owner=context.toDict(content.first_revision.owner),
395
+            last_modification_author=context.toDict(content.last_revision.owner),
394 396
             status=context.toDict(data_container.get_status()),
395 397
             links=[],
396
-            revisions=context.toDict(sorted(content.revisions, key=lambda v: v.created, reverse=True)),
398
+            revision_nb = len(content.revisions),
397 399
             selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
398 400
             history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history()),
399 401
             is_editable=content.is_editable,
@@ -450,16 +452,19 @@ def serialize_content_for_history(event: VirtualEvent, context: Context):
450 452
     )
451 453
 
452 454
 @pod_serializer(Content, CTX.THREAD)
453
-def serialize_node_for_page(item: Content, context: Context):
455
+def serialize_node_for_thread(item: Content, context: Context):
454 456
     if item.type==ContentType.Thread:
455 457
         return DictLikeClass(
456 458
             content = item.description,
457 459
             created = item.created,
460
+            updated = item.last_revision.updated,
461
+            revision_nb = len(item.revisions),
458 462
             icon = ContentType.get_icon(item.type),
459 463
             id = item.content_id,
460 464
             label = item.label,
461 465
             links=[],
462 466
             owner = context.toDict(item.owner),
467
+            last_modification_author=context.toDict(item.last_revision.owner),
463 468
             parent = context.toDict(item.parent),
464 469
             selected_revision = 'latest',
465 470
             status = context.toDict(item.get_status()),
@@ -595,6 +600,9 @@ def serialize_content_for_workspace_and_folder(content: Content, context: Contex
595 600
             id=content.content_id,
596 601
             label=content.label,
597 602
             created=content.created,
603
+            updated=content.last_revision.updated,
604
+            last_modification_author=context.toDict(content.last_revision.owner),
605
+            revision_nb=len(content.revisions),
598 606
             workspace=context.toDict(content.workspace),
599 607
             allowed_content=DictLikeClass(content.properties['allowed_content']),
600 608
             allowed_content_types=context.toDict(content.get_allowed_content_types()),

+ 8 - 1
tracim/tracim/templates/file/getone.mak View File

@@ -51,7 +51,14 @@
51 51
 
52 52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
53 53
                 <% created_localized = h.get_with_timezone(result.file.created) %>
54
-              <p>${_('file created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.file.owner.name)|n}</p>
54
+                <% updated_localized = h.get_with_timezone(result.file.updated) %>
55
+                <% last_modification_author = result.file.last_modification_author.name %>
56
+              <p>${_('file created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.file.owner.name)|n}
57
+                  % if result.file.revision_nb > 1:
58
+                      ${_(' (last modification on {update_date} at {update_time} by {last_modification_author})').format(update_date=h.update_date(updated_localized), update_time=h.update_time(updated_localized), last_modification_author = last_modification_author)|n}
59
+                  % endif
60
+              </p>
61
+
55 62
             </div>
56 63
         </div>
57 64
     </div>

+ 7 - 1
tracim/tracim/templates/folder/getone.mak View File

@@ -50,7 +50,13 @@
50 50
 
51 51
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
52 52
                 <% created_localized = h.get_with_timezone(result.folder.created) %>
53
-              <p>${_('folder created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.folder.owner.name)|n}</p>
53
+                <% updated_localized = h.get_with_timezone(result.folder.updated) %>
54
+                <% last_modification_author = result.folder.last_modification_author.name %>
55
+                <p>${_('folder created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.folder.owner.name)|n}
56
+                    % if result.folder.revision_nb > 1:
57
+                      ${_(' (last modification on {update_date} at {update_time} by {last_modification_author})').format(update_date=h.update_date(updated_localized), update_time=h.update_time(updated_localized), last_modification_author = last_modification_author)|n}
58
+                    % endif
59
+                </p>
54 60
             </div>
55 61
         </div>
56 62
     </div>

+ 8 - 1
tracim/tracim/templates/page/getone.mak View File

@@ -49,7 +49,14 @@
49 49
 
50 50
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
51 51
                 <% created_localized = h.get_with_timezone(result.page.created) %>
52
-              <p>${_('page created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.page.owner.name)|n}</p>
52
+                <% updated_localized = h.get_with_timezone(result.page.updated) %>
53
+                <% last_modification_author = result.page.last_modification_author.name %>
54
+                <p>
55
+                    ${_('page created on {date} at {time} by <b>{author}</b> ').format(date=h.date(created_localized), time=h.time(created_localized), author=result.page.owner.name)|n}
56
+                    % if result.page.revision_nb > 1:
57
+                      ${_('(last modification on {update_date} at {update_time} by {last_modification_author})').format(update_date=h.update_date(updated_localized), update_time=h.update_time(updated_localized), last_modification_author = last_modification_author)|n}
58
+                    % endif
59
+                </p>
53 60
             </div>
54 61
         </div>
55 62
     </div>

+ 8 - 2
tracim/tracim/templates/thread/getone.mak View File

@@ -51,8 +51,14 @@
51 51
 
52 52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
53 53
                 <% created_localized = h.get_with_timezone(result.thread.created) %>
54
-              <p>${_('page created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.thread.owner.name)|n}</p>
55
-            </div>
54
+                <% updated_localized = h.get_with_timezone(result.thread.updated) %>
55
+                <% last_modification_author = result.thread.last_modification_author.name %>
56
+                <p>${_('page created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.thread.owner.name)|n}
57
+                    % if result.thread.revision_nb > 1:
58
+                      ${_(' (last modification on {update_date} at {update_time} by {last_modification_author})').format(update_date=h.update_date(updated_localized), update_time=h.update_time(updated_localized), last_modification_author = last_modification_author)|n}
59
+                    % endif
60
+                </p>
61
+
56 62
         </div>
57 63
     </div>
58 64