From d3d52ca542c5a96463d1d6baee7efa79998a97aa Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Jan 18 2017 16:01:59 +0000
Subject: [PATCH 1/5] fix log action for notifications


---

diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py
index 38962c5..aa6b725 100644
--- a/pagure/lib/__init__.py
+++ b/pagure/lib/__init__.py
@@ -272,7 +272,8 @@ def add_issue_comment(session, issue, comment, user, ticketfolder,
     pagure.lib.git.update_git(
         issue, repo=issue.project, repofolder=ticketfolder)
 
-    log_action(session, 'commented', issue, user_obj)
+    if not notification:
+        log_action(session, 'commented', issue, user_obj)
 
     if notify:
         pagure.lib.notify.notify_new_comment(issue_comment, user=user_obj)
@@ -1461,6 +1462,7 @@ def edit_issue(session, issue, ticketfolder, user,
             notify=False,
             notification=True,
         )
+        log_action(session, status, issue, user_obj)
         pagure.lib.notify.notify_status_change_issue(issue, user_obj)
 
     if not issue.private and edit:
diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index 41d7493..1f272c5 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -1838,18 +1838,24 @@ class PagureLog(BASE):
             'project': self.project.fullname,
         }
 
-        if self.issue and self.log_type == 'created':
-            verb = 'created issue'
-        elif self.issue and self.log_type == 'commented':
-            verb = 'commented on issue'
-        elif self.pull_request and self.log_type == 'created':
-            verb = 'created PR'
-        elif self.pull_request and self.log_type == 'commented':
-            verb = 'commented on PR'
-        elif self.pull_request and self.log_type == 'closed':
-            verb = 'closed PR'
-        elif self.pull_request and self.log_type == 'merged':
-            verb = 'merged PR'
+        if self.issue:
+            if self.log_type == 'created':
+                verb = 'created issue'
+            elif self.log_type == 'commented':
+                verb = 'comment on issue'
+            elif self.log_type == 'close':
+                verb = 'closed issue'
+            elif self.log_type == 'open':
+                verb = 'opened issue'
+        elif self.pull_request:
+            if self.log_type == 'created':
+                verb = 'created PR'
+            elif self.log_type == 'commented':
+                verb = 'comment on PR'
+            elif self.log_type == 'closed':
+                verb = 'closed PR'
+            elif self.log_type == 'merged':
+                verb = 'merged PR'
         elif not self.pull_request and not self.issue \
                 and self.log_type == 'created':
             verb = 'created Project'

From 8e11a7972b1a0887e870be6c18dc07e67e7dd718 Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Jan 18 2017 16:01:59 +0000
Subject: [PATCH 2/5] modify verb creation in PagureLog class


---

diff --git a/pagure/lib/__init__.py b/pagure/lib/__init__.py
index aa6b725..b3e33c3 100644
--- a/pagure/lib/__init__.py
+++ b/pagure/lib/__init__.py
@@ -1462,7 +1462,7 @@ def edit_issue(session, issue, ticketfolder, user,
             notify=False,
             notification=True,
         )
-        log_action(session, status, issue, user_obj)
+        log_action(session, status.lower(), issue, user_obj)
         pagure.lib.notify.notify_status_change_issue(issue, user_obj)
 
     if not issue.private and edit:
diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index 1f272c5..3d518ba 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -1838,24 +1838,23 @@ class PagureLog(BASE):
             'project': self.project.fullname,
         }
 
-        if self.issue:
-            if self.log_type == 'created':
-                verb = 'created issue'
-            elif self.log_type == 'commented':
-                verb = 'comment on issue'
-            elif self.log_type == 'close':
-                verb = 'closed issue'
-            elif self.log_type == 'open':
-                verb = 'opened issue'
-        elif self.pull_request:
-            if self.log_type == 'created':
-                verb = 'created PR'
-            elif self.log_type == 'commented':
-                verb = 'comment on PR'
-            elif self.log_type == 'closed':
-                verb = 'closed PR'
-            elif self.log_type == 'merged':
-                verb = 'merged PR'
+        issue_verb={'created': 'created issue',
+             'commented': 'commented on issue',
+             'close': 'closed issue',
+             'open': 'opened issue',
+        }
+
+        pr_verb={'created': 'created PR',
+            'commented': 'commented on PR',
+            'close': 'closed PR',
+            'open': 'opened PR',
+            'merged': 'merged PR'
+        }
+
+        if self.issue and self.log_type in issue_verb.keys():
+            verb = issue_verb[self.log_type]
+        elif self.pull_request and self.log_type in pr_verb.keys():
+            verb = pr_verb[self.log_type]
         elif not self.pull_request and not self.issue \
                 and self.log_type == 'created':
             verb = 'created Project'

From ca928552561b6c2d03b5c8293128e7dda6b57b5b Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Jan 18 2017 16:01:59 +0000
Subject: [PATCH 3/5] fix PagureLog verbs in model.py


---

diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index 3d518ba..1987643 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -1846,8 +1846,7 @@ class PagureLog(BASE):
 
         pr_verb={'created': 'created PR',
             'commented': 'commented on PR',
-            'close': 'closed PR',
-            'open': 'opened PR',
+            'closed': 'closed PR',
             'merged': 'merged PR'
         }
 

From 92191046c9288648e44bb048e1a6964407473661 Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Jan 18 2017 16:01:59 +0000
Subject: [PATCH 4/5] fix pep8 error in model.py


---

diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index 1987643..ca945b3 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -1838,13 +1838,15 @@ class PagureLog(BASE):
             'project': self.project.fullname,
         }
 
-        issue_verb={'created': 'created issue',
-             'commented': 'commented on issue',
-             'close': 'closed issue',
-             'open': 'opened issue',
+        issue_verb = {
+            'created': 'created issue',
+            'commented': 'commented on issue',
+            'close': 'closed issue',
+            'open': 'opened issue',
         }
 
-        pr_verb={'created': 'created PR',
+        pr_verb = {
+            'created': 'created PR',
             'commented': 'commented on PR',
             'closed': 'closed PR',
             'merged': 'merged PR'

From 86e781608269da267a216e3430076b1bf2e59c80 Mon Sep 17 00:00:00 2001
From: Vibhor Verma <vibhcool@gmail.com>
Date: Jan 18 2017 16:01:59 +0000
Subject: [PATCH 5/5] optimize verb dicts in model.py


---

diff --git a/pagure/lib/model.py b/pagure/lib/model.py
index ca945b3..d0bb402 100644
--- a/pagure/lib/model.py
+++ b/pagure/lib/model.py
@@ -1852,9 +1852,9 @@ class PagureLog(BASE):
             'merged': 'merged PR'
         }
 
-        if self.issue and self.log_type in issue_verb.keys():
+        if self.issue and self.log_type in issue_verb:
             verb = issue_verb[self.log_type]
-        elif self.pull_request and self.log_type in pr_verb.keys():
+        elif self.pull_request and self.log_type in pr_verb:
             verb = pr_verb[self.log_type]
         elif not self.pull_request and not self.issue \
                 and self.log_type == 'created':

