You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2018/06/14 17:41:00 UTC
allura git commit: [#8206] Personal Dashboard - Add helper method to
load sections in Dashboard and Profile
Repository: allura
Updated Branches:
refs/heads/master 7335d7e55 -> 26fad5e4c
[#8206] Personal Dashboard - Add helper method to load sections in Dashboard and Profile
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/26fad5e4
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/26fad5e4
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/26fad5e4
Branch: refs/heads/master
Commit: 26fad5e4c7d3fbd4ee9031a764bc40d38f50a749
Parents: 7335d7e
Author: deshanigtk <de...@cse.mrt.ac.lk>
Authored: Thu Jun 14 00:04:52 2018 +0530
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Jun 14 13:26:44 2018 -0400
----------------------------------------------------------------------
.../ext/personal_dashboard/dashboard_main.py | 13 ++---------
Allura/allura/ext/user_profile/user_main.py | 13 ++---------
Allura/allura/lib/widgets/user_profile.py | 24 ++++++++++++++++++++
3 files changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/26fad5e4/Allura/allura/ext/personal_dashboard/dashboard_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/personal_dashboard/dashboard_main.py b/Allura/allura/ext/personal_dashboard/dashboard_main.py
index 5622c1a..6ce5e5f 100644
--- a/Allura/allura/ext/personal_dashboard/dashboard_main.py
+++ b/Allura/allura/ext/personal_dashboard/dashboard_main.py
@@ -16,7 +16,6 @@
# under the License.
import logging
-import re
import tg
from jinja2 import Markup
@@ -30,6 +29,7 @@ from allura.controllers import BaseController
from allura.controllers.feed import FeedController
from allura.lib import helpers as h
from allura.lib.plugin import AuthenticationProvider
+from allura.lib.widgets.user_profile import SectionsUtil
log = logging.getLogger(__name__)
@@ -40,17 +40,8 @@ class DashboardController(BaseController, FeedController):
def index(self, **kw):
if not c.user.is_anonymous():
user = c.user
- sections = {}
- for ep in h.iter_entry_points('allura.personal_dashboard.sections'):
- sections[ep.name] = ep.load()
- section_ordering = tg.config.get('personal_dashboard_sections.order', '')
- ordered_sections = []
- for section in re.split(r'\s*,\s*', section_ordering):
- if section in sections:
- ordered_sections.append(sections.pop(section))
- dashboard_sections = ordered_sections + sections.values()
sections = [section(user)
- for section in dashboard_sections]
+ for section in SectionsUtil.load_sections('personal_dashboard')]
return dict(user=user, sections=sections, title="Personal Dashboard")
else:
redirect('/neighborhood')
http://git-wip-us.apache.org/repos/asf/allura/blob/26fad5e4/Allura/allura/ext/user_profile/user_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/user_profile/user_main.py b/Allura/allura/ext/user_profile/user_main.py
index 9be9276..3190771 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -16,7 +16,6 @@
# under the License.
import logging
-import re
import pkg_resources
from pylons import tmpl_context as c
@@ -41,7 +40,7 @@ from allura.controllers import BaseController
from allura.controllers.feed import FeedArgs, FeedController
from allura.controllers.rest import AppRestControllerMixin
from allura.lib.decorators import require_post
-from allura.lib.widgets.user_profile import SendMessageForm
+from allura.lib.widgets.user_profile import SendMessageForm, SectionsUtil
log = logging.getLogger(__name__)
@@ -116,15 +115,7 @@ class UserProfileApp(Application):
"""
if hasattr(UserProfileApp, '_sections'):
return UserProfileApp._sections
- sections = {}
- for ep in h.iter_entry_points('allura.user_profile.sections'):
- sections[ep.name] = ep.load()
- section_ordering = tg.config.get('user_profile_sections.order', '')
- ordered_sections = []
- for section in re.split(r'\s*,\s*', section_ordering):
- if section in sections:
- ordered_sections.append(sections.pop(section))
- UserProfileApp._sections = ordered_sections + sections.values()
+ UserProfileApp._sections = SectionsUtil.load_sections('user_profile')
return UserProfileApp._sections
http://git-wip-us.apache.org/repos/asf/allura/blob/26fad5e4/Allura/allura/lib/widgets/user_profile.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/user_profile.py b/Allura/allura/lib/widgets/user_profile.py
index 8746b0e..32c87c4 100644
--- a/Allura/allura/lib/widgets/user_profile.py
+++ b/Allura/allura/lib/widgets/user_profile.py
@@ -15,11 +15,19 @@
# specific language governing permissions and limitations
# under the License.
+import logging
+import re
+
import ew as ew_core
import ew.jinja2_ew as ew
+import tg
from formencode import validators as fev
+
+from allura.lib import helpers as h
from .forms import ForgeForm
+log = logging.getLogger(__name__)
+
class SendMessageForm(ForgeForm):
template = 'jinja:allura.ext.user_profile:templates/send_message_form.html'
@@ -47,3 +55,19 @@ class SendMessageForm(ForgeForm):
label='Message')
cc = ew.Checkbox(label='Send me a copy')
+
+
+class SectionsUtil(object):
+
+ @staticmethod
+ def load_sections(app):
+ sections = {}
+ for ep in h.iter_entry_points('allura.%s.sections' % app):
+ sections[ep.name] = ep.load()
+ section_ordering = tg.config.get('%s_sections.order' % app, '')
+ ordered_sections = []
+ for section in re.split(r'\s*,\s*', section_ordering):
+ if section in sections:
+ ordered_sections.append(sections.pop(section))
+ sections = ordered_sections + sections.values()
+ return sections