From 1c228dab476f7b1ce58a019e26f37725971930af Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Dec 16 2016 11:12:57 +0000 Subject: Issue 1382 - Applying suggestions Fixed copyright date, code styling, and filename parsing --- diff --git a/pagure/ui/diff_style.py b/pagure/ui/diff_style.py index 245104a..e409a77 100644 --- a/pagure/ui/diff_style.py +++ b/pagure/ui/diff_style.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ - (c) 2014-2016 - Copyright Red Hat Inc + (c) 2016 - Copyright Red Hat Inc Authors: Mark Reynolds @@ -96,10 +96,8 @@ class DiffStyle(Style): String.Symbol: "#4e9a06", # class: 'ss' Generic: "#000000", # class: 'g' - Generic.Deleted: 'bg:#ffdddd #a40000', # trac #000000 - Generic.Inserted: 'bg:#ddffdd #00A000', # trac - #Generic.Deleted: "#a40000", # class: 'gd' - #Generic.Inserted: "#00A000", # class: 'gi' + Generic.Deleted: 'bg:#ffdddd #a40000', # trac bg color + Generic.Inserted: 'bg:#ddffdd #00A000', # trac bg color Generic.Emph: "italic #000000", # class: 'ge' Generic.Error: "#ef2929", # class: 'gr' Generic.Heading: "bold #000080", # class: 'gh' diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 10e6760..647ab30 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -167,10 +167,10 @@ def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, status = str(comment.parent.status).lower() if authenticated() and ( ( - status in ['true', 'open'] and - comment.user.user == flask.g.fas_user.username - ) or - is_repo_admin(comment.parent.project)): + status in ['true', 'open'] + and comment.user.user == flask.g.fas_user.username + ) + or is_repo_admin(comment.parent.project)): templ_delete = tpl_delete % ({'commentid': comment.id}) templ_edit = tpl_edit % ({ 'edit_url': flask.url_for( diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index fab3a89..9f9fb23 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -85,6 +85,8 @@ urlpattern = re.compile(urlregex) # URLs + + @APP.route( '//issue//update/', methods=['GET', 'POST']) @@ -163,9 +165,9 @@ def update_issue(repo, issueid, username=None, namespace=None): if comment is None or comment.issue.project != repo: flask.abort(404, 'Comment not found') - if (flask.g.fas_user.username != comment.user.username or - comment.parent.status != 'Open') and not \ - flask.g.repo_admin: + if (flask.g.fas_user.username != comment.user.username + or comment.parent.status != 'Open') \ + and not flask.g.repo_admin: flask.abort( 403, 'You are not allowed to remove this comment from ' @@ -975,8 +977,8 @@ def edit_issue(repo, issueid, username=None, namespace=None): if issue is None or issue.project != repo: flask.abort(404, 'Issue not found') - if not (flask.g.repo_admin or - flask.g.fas_user.username == issue.user.username): + if not (flask.g.repo_admin + or flask.g.fas_user.username == issue.user.username): flask.abort( 403, 'You are not allowed to edit issues for this project') @@ -1159,7 +1161,7 @@ def view_issue_raw_file( if (filename.endswith('.patch') or filename.endswith('.diff')) \ and not is_binary_string(content.data): # We have a patch file attached to this issue, render the diff in html - orig_filename = filename.split('-', 1)[1] + orig_filename = filename.partition('-')[2] return flask.render_template( 'patchfile.html', select='issues', @@ -1200,7 +1202,7 @@ def view_issue_raw_file( @APP.route('//issue//comment//edit', methods=('GET', 'POST')) -@APP.route('///issue//comment//' + +@APP.route('///issue//comment//' 'edit', methods=('GET', 'POST')) @APP.route('/fork///issue//comment' '//edit', methods=('GET', 'POST')) @@ -1229,8 +1231,8 @@ def edit_comment_issue( if comment is None or comment.parent.project != project: flask.abort(404, 'Comment not found') - if (flask.g.fas_user.username != comment.user.username or - comment.parent.status != 'Open') \ + if (flask.g.fas_user.username != comment.user.username + or comment.parent.status != 'Open') \ and not flask.g.repo_admin: flask.abort(403, 'You are not allowed to edit this comment')