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/07/06 18:26:25 UTC

[3/3] allura git commit: [#8215] Personal Dashboard - Create Merge Requests Section

[#8215] Personal Dashboard - Create Merge Requests Section


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/1e8a47e0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/1e8a47e0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/1e8a47e0

Branch: refs/heads/master
Commit: 1e8a47e0ca2cf300bd2849504a00d0027adbd789
Parents: 1d155ce
Author: deshanigtk <de...@cse.mrt.ac.lk>
Authored: Thu Jul 5 00:13:38 2018 +0530
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Fri Jul 6 14:18:59 2018 -0400

----------------------------------------------------------------------
 .../ext/personal_dashboard/dashboard_main.py    | 20 ++++++++++++
 .../templates/sections/merge_requests.html      | 33 +++++++++++++++++++-
 Allura/allura/model/auth.py                     |  7 +++++
 3 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1e8a47e0/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 dd751cf..d5676b7 100644
--- a/Allura/allura/ext/personal_dashboard/dashboard_main.py
+++ b/Allura/allura/ext/personal_dashboard/dashboard_main.py
@@ -110,6 +110,26 @@ class TicketsSection(DashboardSectionBase):
 class MergeRequestsSection(DashboardSectionBase):
     template = 'allura.ext.personal_dashboard:templates/sections/merge_requests.html'
 
+    def get_merge_requests(self):
+        return [
+            merge_request
+            for merge_request in self.user.my_merge_requests()]
+
+    def prepare_context(self, context):
+        context['requests'] = self.get_merge_requests()
+        return context
+
+    def __json__(self):
+        merge_requests = [
+            dict(
+                status=merge_request['status'],
+                summary=merge_request['summary'],
+                repository=merge_request['repository'],
+                created=merge_request['created'],
+                updated=merge_request['updated'])
+            for merge_request in self.get_merge_requests()]
+        return dict(merge_requests=merge_requests)
+
 
 class FollowersSection(DashboardSectionBase):
     template = 'allura.ext.personal_dashboard:templates/sections/followers.html'

http://git-wip-us.apache.org/repos/asf/allura/blob/1e8a47e0/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html b/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
index 10c2dcb..ba9740d 100644
--- a/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
+++ b/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
@@ -17,6 +17,8 @@
        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 %}
     Merge Requests
@@ -26,4 +28,33 @@
 
 {% block section_class %}merge_requests{% endblock %}
 
-{% block content %}{% endblock %}
+{% block content %}
+    <table>
+        <thead>
+        <tr>
+            <th>#</th>
+            <th>Status</th>
+            <th>Summary</th>
+            <th>Repository</th>
+            <th>Created</th>
+            <th>Updated</th>
+        </tr>
+        </thead>
+        <tbody>
+        {% for req in requests %}
+            <tr>
+                <td><a href="{{ req.request_number }}/">{{ req.request_number }}</a></td>
+                <td><a href="{{ req.request_number }}/">{{ req.status }}</a></td>
+                <td><a href="{{ req.request_number }}/">{{ req.summary }}</a></td>
+                <td>{% if req.downstream_repo %}
+                    <a href="{{ req.downstream_url }}">{{ req.downstream_url }}</a>
+                {% else %}
+                    <i>(deleted)</i>
+                {% endif %}</td>
+                <td>{{ lib.abbr_date(req.created) }}</td>
+                <td>{{ lib.abbr_date(req.mod_date) }}</td>
+            </tr>
+        {% endfor %}
+        </tbody>
+    </table>
+{% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/1e8a47e0/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 65e83b4..0abdaa5 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -735,6 +735,13 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
         from .project import Project
 
         return Project.query.find({'_id': {'$in': projects}, 'deleted': False}).all()
+    def my_merge_requests(self):
+        if self.is_anonymous():
+            return
+
+        from .repository import MergeRequest
+
+        return MergeRequest.query.find({'creator_id': self._id}).sort('request_number', pymongo.ASCENDING)
 
     def set_password(self, new_password):
         return plugin.AuthenticationProvider.get(request).set_password(