Browse Source

Merge branch 'master' of github.com:tracim/tracim into integration_v2

Skylsmoi 8 years ago
parent
commit
3d2ce79d63

+ 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

+ 3 - 1
tracim/tracim/config/app_cfg.py View File

@@ -173,7 +173,9 @@ class CFG(object):
173 173
         :param value:
174 174
         :return:
175 175
         """
176
-        if 'PASSWORD' not in key and 'URL' not in key and 'CONTENT' not in key:
176
+        if 'PASSWORD' not in key and \
177
+                ('URL' not in key or type(value) == str) and \
178
+                'CONTENT' not in key:
177 179
             # We do not show PASSWORD for security reason
178 180
             # we do not show URL because the associated config uses tg.lurl() which is evaluated when at display time.
179 181
             # At the time of configuration setup, it can't be evaluated

+ 25 - 1
tracim/tracim/controllers/admin/user.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 import uuid
3
+import random
3 4
 
4 5
 import pytz
5 6
 from tracim import model  as pm
@@ -7,6 +8,7 @@ from tracim import model  as pm
7 8
 from sprox.tablebase import TableBase
8 9
 from sprox.formbase import EditableForm, AddRecordForm
9 10
 from sprox.fillerbase import TableFiller, EditFormFiller
11
+from tracim.config.app_cfg import CFG
10 12
 from tw2 import forms as tw2f
11 13
 import tg
12 14
 from tg import predicates
@@ -273,6 +275,11 @@ class UserRestController(TIMRestController):
273 275
     profile = UserProfileAdminRestController()
274 276
     workspaces = UserWorkspaceRestController()
275 277
 
278
+    PASSWORD_LENGTH = 12
279
+    PASSWORD_CHARACTERS = '0123456789' \
280
+                          'abcdefghijklmonpqrstuvwxyz' \
281
+                          'ABCDEFGHIJKLMONPQRSTUVWXYZ'
282
+
276 283
     @classmethod
277 284
     def current_item_id_key_in_context(cls):
278 285
         return 'user_id'
@@ -326,7 +333,7 @@ class UserRestController(TIMRestController):
326 333
             user.password = password
327 334
         elif send_email:
328 335
             # Setup a random password to send email at user
329
-            password = str(uuid.uuid4())
336
+            password = self.generate_password()
330 337
             user.password = password
331 338
 
332 339
         user.webdav_left_digest_response_hash = '%s:/:%s' % (email, password)
@@ -351,6 +358,23 @@ class UserRestController(TIMRestController):
351 358
         tg.flash(_('User {} created.').format(user.get_display_name()), CST.STATUS_OK)
352 359
         tg.redirect(self.url())
353 360
 
361
+    @classmethod
362
+    def generate_password(
363
+            cls,
364
+            password_length = PASSWORD_LENGTH,
365
+            password_chars = PASSWORD_CHARACTERS
366
+            ):
367
+
368
+        # character list that will be contained into the password
369
+        char_list = []
370
+
371
+        for j in range(0, password_length):
372
+            # This puts a random char from the list above inside
373
+            # the list of chars and then merges them into a String
374
+            char_list.append(random.choice(password_chars))
375
+            password = ''.join(char_list)
376
+        return password
377
+
354 378
     @tg.expose('tracim.templates.admin.user_getone')
355 379
     def get_one(self, user_id):
356 380
         current_user = tmpl_context.current_user

+ 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

@@ -50,7 +50,14 @@
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.file.created) %>
53
-              <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>
53
+                <% updated_localized = h.get_with_timezone(result.file.updated) %>
54
+                <% last_modification_author = result.file.last_modification_author.name %>
55
+              <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}
56
+                  % if result.file.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>
60
+
54 61
             </div>
55 62
         </div>
56 63
     </div>

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

@@ -49,7 +49,13 @@
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.folder.created) %>
52
-              <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>
52
+                <% updated_localized = h.get_with_timezone(result.folder.updated) %>
53
+                <% last_modification_author = result.folder.last_modification_author.name %>
54
+                <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}
55
+                    % if result.folder.revision_nb > 1:
56
+                      ${_(' (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}
57
+                    % endif
58
+                </p>
53 59
             </div>
54 60
         </div>
55 61
     </div>

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

@@ -48,7 +48,14 @@
48 48
 
49 49
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
50 50
                 <% created_localized = h.get_with_timezone(result.page.created) %>
51
-              <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>
51
+                <% updated_localized = h.get_with_timezone(result.page.updated) %>
52
+                <% last_modification_author = result.page.last_modification_author.name %>
53
+                <p>
54
+                    ${_('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}
55
+                    % if result.page.revision_nb > 1:
56
+                      ${_('(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}
57
+                    % endif
58
+                </p>
52 59
             </div>
53 60
         </div>
54 61
     </div>

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

@@ -50,8 +50,14 @@
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.thread.created) %>
53
-              <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>
54
-            </div>
53
+                <% updated_localized = h.get_with_timezone(result.thread.updated) %>
54
+                <% last_modification_author = result.thread.last_modification_author.name %>
55
+                <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}
56
+                    % if result.thread.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>
60
+
55 61
         </div>
56 62
     </div>
57 63