Commits

joberschweiber committed e66c5dc

Issue creation/update goes into journal

Comments (0)

Files changed (5)

rhodecode/controllers/issue.py

 from rhodecode.lib.helpers import Page
 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 from rhodecode.lib.base import BaseRepoController, render
+from rhodecode.lib.utils import action_logger
 
 log = logging.getLogger(__name__)
 
 			c.page = request.params['page']
 
 		self.__update_labels(comment)		
+		
+		action_logger(c.rhodecode_user, 'issue_updated:' + str(comment.issue_no) + ',' + str(comment.comment_no), c.rhodecode_db_repo, sa=self.sa)
 
 		from rhodecode.lib.celerylib import tasks, run_task
 		run_task(tasks.send_issue_notifications, dbrepo.repo_id, issue_no, comment.comment_no)
 		c.stati = json_formatted_status_presets(self.sa, dbrepo.repo_id)
 		c.common_labels = json_formatted_common_labels(self.sa, dbrepo.repo_id)
 
+
 		return render('issue/new.html')
 	
 	def __insert_label(self, repo_id, issue_no, key, value):
 			i += 1
 
 		self.sa.commit()
+		action_logger(c.rhodecode_user, 'issue_created:' + str(issue.issue_no), c.rhodecode_db_repo, sa=self.sa)
+		self.sa.commit()
 		
 		return redirect(url('issue_home', repo_name=repo_name, issue_no=issue.issue_no))
 

rhodecode/controllers/journal.py

 from rhodecode.lib.helpers import Page
 from rhodecode.lib.auth import LoginRequired, NotAnonymous
 from rhodecode.lib.base import BaseController, render
-from rhodecode.model.db import UserLog, UserFollowing
+from rhodecode.model.db import UserLog, UserFollowing, Issue
 
 log = logging.getLogger(__name__)
 

rhodecode/lib/helpers.py

            'pull':'down_16.png',
            'started_following_repo':'heart_add.png',
            'stopped_following_repo':'heart_delete.png',
+           'issue_created':'bug_add.png',
+           'issue_updated':'bug_edit.png'
             }
     return literal(tmpl % ((url('/images/icons/')),
                            map.get(action, action), action))

rhodecode/model/db.py

     def action_as_day(self):
         return date(*self.action_date.timetuple()[:3])
 
+    @property
+    def issue(self):
+        if ',' in self.action:
+            return Session.query(Issue).get((self.repository_id, self.action.split(':')[1].split(',')[0]))
+        else:
+            return Session.query(Issue).get((self.repository_id, self.action.split(':')[1]))
+
+    @property
+    def issue_comment(self):
+        return Session.query(IssueComment).get((self.repository_id, self.action.split(':')[1].split(',')[0], self.action.split(':')[1].split(',')[1]))
+
     user = relationship('User')
     repository = relationship('Repository')
 

rhodecode/templates/journal/journal_data.html

 ${h.link_to(item.repository.repo_name, h.url('files_home', repo_name=item.repository.repo_name))}
 </%def>
 
+<%def name="issue_link(item)">
+%if ',' in item.action:
+${h.link_to('#' + item.action.split(':')[1].split(',')[0], h.url('issue_home', repo_name=item.repository.repo_name, issue_no=item.action.split(':')[1].split(',')[0]))}
+%else:
+${h.link_to('#' + item.action.split(':')[1], h.url('issue_home', repo_name=item.repository.repo_name, issue_no=item.action.split(':')[1]))}
+%endif
+</%def>
+
 <%def name="boilerplate(item)">
   <div class="entry">
     ${self.icon(item)}
     ${h.age(item.action_date)}
     </div>
     </div>
+  %elif item.action.startswith('issue_created'):
+    ${self.boilerplate(item)}
+    <span class="action">${_('opened issue')}</span> ${self.issue_link(item)} ${_('in')} 
+    ${self.repo_link(item)}
+    ${h.age(item.action_date)}
+    <div class="details">
+        ${item.issue.summary}
+    </div>  
+    </div>
+    </div>  
+  %elif item.action.startswith('issue_updated'):
+    ${self.boilerplate(item)}
+    <span class="action">${_('updated issue')}</span> ${self.issue_link(item)} ${_('in')}
+    ${self.repo_link(item)}
+    ${h.age(item.action_date)}
+    <div class="details">
+        ${item.issue_comment.text}
+    </div>
+    </div>
+    </div>
   %endif
 %endfor