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/19 16:35:13 UTC
allura git commit: [#8208] Personal Dashboard - Create Projects
section
Repository: allura
Updated Branches:
refs/heads/master a5eefccaf -> 93eaaa279
[#8208] Personal Dashboard - Create Projects section
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/93eaaa27
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/93eaaa27
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/93eaaa27
Branch: refs/heads/master
Commit: 93eaaa279cd361e6ea2c1d58e32302eb806febb5
Parents: a5eefcc
Author: deshanigtk <de...@cse.mrt.ac.lk>
Authored: Mon Jun 18 09:29:01 2018 +0530
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Tue Jun 19 12:34:47 2018 -0400
----------------------------------------------------------------------
.../ext/personal_dashboard/dashboard_main.py | 6 +--
.../templates/sections/projects.html | 41 +++++++++++++++++++-
Allura/allura/ext/user_profile/user_main.py | 27 +------------
Allura/allura/lib/widgets/user_profile.py | 26 +++++++++++++
4 files changed, 70 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/93eaaa27/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 f374f16..6bfe227 100644
--- a/Allura/allura/ext/personal_dashboard/dashboard_main.py
+++ b/Allura/allura/ext/personal_dashboard/dashboard_main.py
@@ -22,8 +22,8 @@ from tg import expose, redirect
from allura.controllers import BaseController
from allura.controllers.feed import FeedController
-from allura.lib.widgets.user_profile import SectionBase
-from allura.lib.widgets.user_profile import SectionsUtil
+from allura.lib.widgets.user_profile import SectionBase, SectionsUtil, ProjectsSectionBase
+
log = logging.getLogger(__name__)
@@ -56,7 +56,7 @@ class DashboardSectionBase(SectionBase):
"""
-class ProjectsSection(DashboardSectionBase):
+class ProjectsSection(DashboardSectionBase, ProjectsSectionBase):
template = 'allura.ext.personal_dashboard:templates/sections/projects.html'
http://git-wip-us.apache.org/repos/asf/allura/blob/93eaaa27/Allura/allura/ext/personal_dashboard/templates/sections/projects.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/personal_dashboard/templates/sections/projects.html b/Allura/allura/ext/personal_dashboard/templates/sections/projects.html
index fa24167..5616ce0 100644
--- a/Allura/allura/ext/personal_dashboard/templates/sections/projects.html
+++ b/Allura/allura/ext/personal_dashboard/templates/sections/projects.html
@@ -17,13 +17,50 @@
under the License.
-#}
{% extends "allura.ext.personal_dashboard:templates/dashboard_section_base.html" %}
+{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+{% import g.theme.jinja_macros as theme_macros with context %}
{% block title %}
Projects
{% endblock %}
-{% block actions %}{% endblock %}
+{% block actions %}
+ {% if user == c.user %}
+ <a href="/{{ config.get('default_neighborhood', 'p') }}/add_project">Add Project</a>
+ {% endif %}
+{% endblock %}
{% block section_class %}projects{% endblock %}
-{% block content %}{% endblock %}
+{% block content %}
+ <ul>
+ {% for project in projects %}
+ <li{% if loop.index > 5 %} class="hidden"{% endif %}>
+ {% if project.icon -%}
+ <img {{ lib.project_icon_srcs(project) }} alt="Project Logo" width="48" height="48"/>
+ {%- else -%}
+ {{ theme_macros.placeholder_project_icon() }}
+ {%- endif -%}
+ <span class="project-info">
+ <a href="{{ project.url() }}">{{ project.name }}</a>
+ {{ project.summary or ' '|safe }}
+ </span>
+ <span class="project-last-updated">
+ Last Updated:
+ <time datetime="{{ project.last_updated }}" title="{{ project.last_updated }}">
+ {{ h.ago(project.last_updated) }}
+ </time>
+ </span>
+ </li>
+ {% else %}
+ <li class="empty">No projects to display.</li>
+ {% endfor %}
+ </ul>
+ {% if projects|length > 5 %}
+ <div class="show-more-projects">
+ <button onclick="$(this).hide().closest('.section-body').find('li.hidden').show()">
+ {{ g.icons['add'].render(title='Show More', show_title=True, tag='b') }}
+ </button>
+ </div>
+ {% endif %}
+{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/93eaaa27/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 1e434ed..3bd782e 100644
--- a/Allura/allura/ext/user_profile/user_main.py
+++ b/Allura/allura/ext/user_profile/user_main.py
@@ -36,7 +36,7 @@ from allura.lib import helpers as h
from allura.lib.decorators import require_post
from allura.lib.plugin import AuthenticationProvider
from allura.lib.security import require_access
-from allura.lib.widgets.user_profile import SendMessageForm, SectionsUtil, SectionBase
+from allura.lib.widgets.user_profile import SendMessageForm, SectionsUtil, SectionBase, ProjectsSectionBase
from allura.model import User, ACE, ProjectRole
log = logging.getLogger(__name__)
@@ -265,32 +265,9 @@ class PersonalDataSection(ProfileSectionBase):
availability=self.user.get_pref('availability')._deinstrument())
-class ProjectsSection(ProfileSectionBase):
+class ProjectsSection(ProfileSectionBase, ProjectsSectionBase):
template = 'allura.ext.user_profile:templates/sections/projects.html'
- def get_projects(self):
- return [
- project
- for project in self.user.my_projects()
- if project != c.project
- and (self.user == c.user or h.has_access(project, 'read'))
- and not project.is_nbhd_project
- and not project.is_user_project]
-
- def prepare_context(self, context):
- context['projects'] = self.get_projects()
- return context
-
- def __json__(self):
- projects = [
- dict(
- name=project['name'],
- url=project.url(),
- summary=project['summary'],
- last_updated=project['last_updated'])
- for project in self.get_projects()]
- return dict(projects=projects)
-
class SkillsSection(ProfileSectionBase):
template = 'allura.ext.user_profile:templates/sections/skills.html'
http://git-wip-us.apache.org/repos/asf/allura/blob/93eaaa27/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 fbfeb07..c37cde9 100644
--- a/Allura/allura/lib/widgets/user_profile.py
+++ b/Allura/allura/lib/widgets/user_profile.py
@@ -132,3 +132,29 @@ class SectionBase(object):
raise
else:
return ''
+
+
+class ProjectsSectionBase(SectionBase):
+
+ def get_projects(self):
+ return [
+ project
+ for project in self.user.my_projects()
+ if project != c.project
+ and (self.user == c.user or h.has_access(project, 'read'))
+ and not project.is_nbhd_project
+ and not project.is_user_project]
+
+ def prepare_context(self, context):
+ context['projects'] = self.get_projects()
+ return context
+
+ def __json__(self):
+ projects = [
+ dict(
+ name=project['name'],
+ url=project.url(),
+ summary=project['summary'],
+ last_updated=project['last_updated'])
+ for project in self.get_projects()]
+ return dict(projects=projects)