diff --git a/pagure/templates/_render_pullrequests.html b/pagure/templates/_render_pullrequests.html index 63baa79..d5e5abc 100644 --- a/pagure/templates/_render_pullrequests.html +++ b/pagure/templates/_render_pullrequests.html @@ -1,4 +1,4 @@ -{% macro render_pullrequest_row(request, repo, username, subtitle=True) %} +{% macro render_pullrequest_row(request, repo, username, subtitle=True, class="", showproject=False) %} {% if request.status|lower == 'open' %} {% set status_color = "success" %} {% elif request.status|lower == 'merged' %} @@ -7,10 +7,11 @@ {% set status_color = "danger" %} {% endif %} -
+
-
+
+
#{{request.id}} @@ -23,10 +24,30 @@ {{request.title}} -
+ + + {% if request.assignee %} + + + {{ request.assignee.username | avatar(size=20) | safe}} + + {% endif %} + + + + {{request.branch}} + + + + + {{request.user_comments|count}} + + + +
{% if subtitle %} -
+
{% if request.status|lower == 'merged'%} Merged @@ -63,8 +84,40 @@ }}">{{ request.last_updated | humanize}} {% endif %} + {% if showproject %} + + {% if repo.is_fork -%} +   + {%- else -%} +   + {%- endif -%} + {% if repo.is_fork %} + {{ repo.user.user }} / + {% endif %} + {% if repo.namespace %} + {{ repo.namespace }}/ + {% endif %} + {% if repo.is_fork %} + + {% else %} + + {% endif %} + {{ repo.name }} + + {% endif %}
- {% endif %}
{% for tag in request.tags %} {% endfor %}
+ {% endif %}
- - - {% if request.assignee %} - - - {{ request.assignee.username | avatar(size=20) | safe}} - - {% endif %} - - - - {{request.branch}} - - - - - {{request.user_comments|count}} - - -
{% endmacro%} diff --git a/pagure/templates/user_requests.html b/pagure/templates/user_requests.html deleted file mode 100644 index d2406f0..0000000 --- a/pagure/templates/user_requests.html +++ /dev/null @@ -1,173 +0,0 @@ -{% extends "master.html" %} - -{% block title %}Pull Requests for {{ username }}{% endblock %} - - -{% block content %} -
-
-

- Pull Requests for {{ username | avatar(20) | safe }} {{ username }} -

-
- - Open - Merged - Closed - All - -
-
- - {% for pullrequests in ( - requests|selectattr("user.username", "equalto", username), - requests|rejectattr("user.username", "equalto", username)) %} - {% if loop.first %} - {% set id="my-pr-table" %} - - Pull Requests opened by {{ username | avatar(20) | safe }} - {{ username }} - - {% else %} - {% set id="pr-table" %} - - Pull Requests {{ username | avatar(20) | safe }} - {{ username }} can act on - - {% endif %} - - - - - - - - - - - - - - - - - {% for request in pullrequests %} - - - - - - - - - - - {% endfor %} - - - - -
#StatusTitleMerge StatusOpenedProjectOpened byAssigned to
- PR#{{ request.id }} - - {{request.status}} - - - - {{ request.title | noJS("img") | safe }} - - - - {{request.merge_status or 'No Status' | lower}} - - - {{ - request.date_created | humanize}} - - - {{ request.project.user.username + '/' if request.project.is_fork }} - {{ request.project.namespace + '/' if request.project.namespace }} - {{ request.project.name }} - - - {{ request.user.default_email | avatar(16) | safe }} - {{ request.user.username }} - - {% if request.assignee %} - {{ request.assignee.default_email | avatar(16) | safe }} - {{ request.assignee.user }} - {% else %} - unassigned - {% endif %} -
-
- {% endfor %} -
-
- -{% endblock %} - -{% block jscripts %} - {{ super() }} - -{% endblock %} diff --git a/pagure/templates/userprofile_master.html b/pagure/templates/userprofile_master.html index a254b56..a0cd093 100644 --- a/pagure/templates/userprofile_master.html +++ b/pagure/templates/userprofile_master.html @@ -104,6 +104,15 @@ +
diff --git a/pagure/templates/userprofile_pullrequests.html b/pagure/templates/userprofile_pullrequests.html new file mode 100644 index 0000000..c4df088 --- /dev/null +++ b/pagure/templates/userprofile_pullrequests.html @@ -0,0 +1,97 @@ +{% extends "userprofile_master.html" %} + +{% block title %}Pull Requests for {{ username }}{% endblock %} + +{% from "_render_pullrequests.html" import render_pullrequest_row %} + +{% block userprofile_content %} +
+
+
+

+ Pull Requests for {{ username | avatar(20) | safe }} {{ username }} +

+
+ + Open + Merged + Cancelled + All + +
+
+ +
+
Pull Requests Created
+ + PRs + +
+ + {% for request in requests|selectattr("user.username", "equalto", username) %} + {% if request.status|lower != "open" %} + {% set hidden = "hidden "%} + {% else %} + {% set hidden = "" %} + {% endif %} + {% set htmlclass = hidden+"pr-created pr-status pr-status-"+request.status|lower%} + {{render_pullrequest_row(request, request.project, username, class=htmlclass, showproject=True)}} + {% endfor %} + + +
+
Pull Requests {{username}} can act on
+ + PRs + +
+ + {% for request in requests|rejectattr("user.username", "equalto", username) %} + {% if request.status|lower != "open" %} + {% set hidden = "hidden "%} + {% else %} + {% set hidden = "" %} + {% endif %} + {% set htmlclass = hidden+"pr-assigned pr-status pr-status-"+request.status|lower%} + {{render_pullrequest_row(request, request.project, username, class=htmlclass, showproject=True)}} + {% endfor %} +
+
+ +{% endblock %} + +{% block jscripts %} + {{ super() }} + +{% endblock %} diff --git a/pagure/ui/app.py b/pagure/ui/app.py index 96ba9f0..b9c0597 100644 --- a/pagure/ui/app.py +++ b/pagure/ui/app.py @@ -891,8 +891,16 @@ def view_user_requests(username): flask.g.session, username=username ) + userprofile_common = get_userprofile_common(user) + return flask.render_template( - "user_requests.html", username=username, user=user, requests=requests + "userprofile_pullrequests.html", + username=username, + user=user, + requests=requests, + select="requests", + repos_length=userprofile_common["repos_length"], + forks_length=userprofile_common["forks_length"], ) diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py index 481c2f4..9e6e3be 100644 --- a/tests/test_pagure_flask_ui_app.py +++ b/tests/test_pagure_flask_ui_app.py @@ -1491,7 +1491,7 @@ class PagureFlaskApptests(tests.Modeltests): output_text = output.get_data(as_text=True) self.assertIn('test pull-request #1', output_text) self.assertEqual( - output_text.count('(.*?)
', output_text, re.M | re.S) + tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) self.assertEqual(output.status_code, 200) # Make sure that issue four is first since it was modified last self.assertIn('href="/test/pull-request/4"', tr_elements[0]) @@ -963,7 +963,7 @@ class PagureFlaskForktests(tests.Modeltests): # sort by last_updated output = self.app.get('/test/pull-requests?order_key=last_updated') output_text = output.get_data(as_text=True) - tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) + tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) self.assertEqual(output.status_code, 200) # Make sure that PR four is first since it was modified last self.assertIn('href="/test/pull-request/1"', tr_elements[0]) @@ -977,7 +977,7 @@ class PagureFlaskForktests(tests.Modeltests): output = self.app.get('/test/pull-requests?' 'order_key=last_updated&order=asc') output_text = output.get_data(as_text=True) - tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) + tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) self.assertIn('href="/test/pull-request/2"', tr_elements[0]) self.assertIn('href="/test/pull-request/4"', tr_elements[1]) self.assertIn('href="/test/pull-request/1"', tr_elements[2]) @@ -985,13 +985,13 @@ class PagureFlaskForktests(tests.Modeltests): #check that search_pattern argument works output = self.app.get('/test/pull-requests?search_pattern=feature') output_text = output.get_data(as_text=True) - tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) + tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) self.assertIn('href="/test/pull-request/1"', tr_elements[0]) self.assertEqual(len(tr_elements), 1) output = self.app.get('/test/pull-requests?search_pattern=PR') output_text = output.get_data(as_text=True) - tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) + tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) self.assertIn('href="/test/pull-request/4"', tr_elements[0]) self.assertIn('href="/test/pull-request/2"', tr_elements[1]) self.assertIn('href="/test/pull-request/1"', tr_elements[2]) @@ -999,7 +999,7 @@ class PagureFlaskForktests(tests.Modeltests): output = self.app.get('/test/pull-requests?search_pattern=*PR') output_text = output.get_data(as_text=True) - tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) + tr_elements = re.findall('
(.*?)
', output_text, re.M | re.S) self.assertEqual(len(tr_elements), 1) self.assertIn('href="/test/pull-request/2"', tr_elements[0]) diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py index 7cce469..ba77933 100644 --- a/tests/test_pagure_flask_ui_issues.py +++ b/tests/test_pagure_flask_ui_issues.py @@ -898,7 +898,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Sort by last_updated output = self.app.get('/test/issues?order_key=last_updated') self.assertEqual(output.status_code, 200) - tr_elements = re.findall(r'
(.*?)
', + tr_elements = re.findall(r'
(.*?)
', output.get_data(as_text=True), re.M | re.S) # Make sure that issue four is first since it was modified last self.assertIn('href="/test/issue/4"', tr_elements[0]) @@ -914,7 +914,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.session.commit() output = self.app.get('/test/issues?order_key=last_updated') self.assertEqual(output.status_code, 200) - tr_elements = re.findall(r'
(.*?)
', + tr_elements = re.findall(r'
(.*?)
', output.get_data(as_text=True), re.M | re.S) # Make sure that issue one is first since it was modified last self.assertIn('href="/test/issue/1"', tr_elements[0]) @@ -926,7 +926,7 @@ class PagureFlaskIssuestests(tests.Modeltests): self.assertIn('href="/test/issue/2"', tr_elements[2]) # Now query so that the results are ascending output = self.app.get('/test/issues?order_key=last_updated&order=asc') - tr_elements = re.findall(r'
(.*?)
', + tr_elements = re.findall(r'
(.*?)
', output.get_data(as_text=True), re.M | re.S) self.assertIn('href="/test/issue/2"', tr_elements[0]) @@ -936,7 +936,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Sort by title descending output = self.app.get('/test/issues?order_key=title') self.assertEqual(output.status_code, 200) - tr_elements = re.findall(r'
(.*?)
', + tr_elements = re.findall(r'
(.*?)
', output.get_data(as_text=True), re.M | re.S) self.assertIn('href="/test/issue/2"', tr_elements[0]) @@ -946,7 +946,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Sort by title ascending output = self.app.get('/test/issues?order_key=title&order=asc') self.assertEqual(output.status_code, 200) - tr_elements = re.findall(r'
(.*?)
', + tr_elements = re.findall(r'
(.*?)
', output.get_data(as_text=True), re.M | re.S) self.assertIn('href="/test/issue/4"', tr_elements[0]) @@ -956,7 +956,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Sort by user (reporter/author) descending output = self.app.get('/test/issues?order_key=user&order=desc') self.assertEqual(output.status_code, 200) - tr_elements = re.findall(r'
(.*?)
', + tr_elements = re.findall(r'
(.*?)
', output.get_data(as_text=True), re.M | re.S) # We check that they are unassigned, otherwise our previous check is @@ -970,7 +970,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Sort by user (reporter/author) ascending output = self.app.get('/test/issues?order_key=user&order=asc') self.assertEqual(output.status_code, 200) - tr_elements = re.findall(r'
(.*?)
', + tr_elements = re.findall(r'
(.*?)
', output.get_data(as_text=True), re.M | re.S) # Check for the name after the avatar @@ -1003,7 +1003,7 @@ class PagureFlaskIssuestests(tests.Modeltests): # Sort by assignee descending output = self.app.get('/test/issues?order_key=assignee&order=desc') self.assertEqual(output.status_code, 200) - #tr_elements = re.findall(r'
(.*?)
', + #tr_elements = re.findall(r'
(.*?)
', # output.get_data(as_text=True), re.M | re.S) #arrowed_th = ('Assignee\n ')