allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 02/03: [#8330] show nicer names where user-projects are (like user tools' <title>)
Date Fri, 30 Aug 2019 17:34:07 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8330
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 3d43d1d504807130c7fcb6b8d944fb5545a965c1
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Fri Aug 30 12:57:01 2019 -0400

    [#8330] show nicer names where user-projects are (like user tools' <title>)
---
 .../allura/ext/user_profile/templates/send_message.html  |  2 +-
 Allura/allura/ext/user_profile/templates/user_index.html |  2 +-
 Allura/allura/model/project.py                           | 16 +++++++++++++++-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/Allura/allura/ext/user_profile/templates/send_message.html b/Allura/allura/ext/user_profile/templates/send_message.html
index 82fc3a9..6745906 100644
--- a/Allura/allura/ext/user_profile/templates/send_message.html
+++ b/Allura/allura/ext/user_profile/templates/send_message.html
@@ -19,7 +19,7 @@
 {% set hide_left_bar = True %}
 {% extends g.theme.master %}
 
-{% block title %}{{user.display_name}} / Profile{% endblock %}
+{% block title %}{{user.username}} / Profile{% endblock %}
 
 {% block header %}Send a Message{% endblock %}
 
diff --git a/Allura/allura/ext/user_profile/templates/user_index.html b/Allura/allura/ext/user_profile/templates/user_index.html
index 1ac5231..9d448c7 100644
--- a/Allura/allura/ext/user_profile/templates/user_index.html
+++ b/Allura/allura/ext/user_profile/templates/user_index.html
@@ -19,7 +19,7 @@
 {% set hide_left_bar = True %}
 {% extends g.theme.master %}
 
-{% block title %}{{user.display_name}} / Profile{% endblock %}
+{% block title %}{{user.username}} / Profile{% endblock %}
 
 {% block header %}{{ user.display_name|default(user.username) }}{% endblock %}
 
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 04fe67f..12d9155 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -184,6 +184,20 @@ class TroveCategory(MappedClass):
         )
 
 
+class ProjectNameFieldProperty(FieldProperty):
+    """
+    Make project names be the username instead of u/whatever, when a user-project.
+    Particularly nice if the username and user-project name don't match exactly.
+    (This is a python "descriptor")
+    """
+    def __get__(self, instance, cls=None):
+        if instance:
+            owning_user = instance.user_project_of
+            if owning_user:
+                return owning_user.username
+        return super(ProjectNameFieldProperty, self).__get__(instance, cls)
+
+
 class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
     '''
     Projects contain tools, subprojects, and their own metadata.  They live
@@ -213,7 +227,7 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
     parent_id = FieldProperty(S.ObjectId, if_missing=None)
     neighborhood_id = ForeignIdProperty(Neighborhood)
     shortname = FieldProperty(str)
-    name = FieldProperty(str)
+    name = ProjectNameFieldProperty(str)
     show_download_button = FieldProperty(S.Deprecated)
     short_description = FieldProperty(str, if_missing='')
     summary = FieldProperty(str, if_missing='')


Mime
View raw message