diff --git a/code_comments/comment.py b/code_comments/comment.py index 1608477..e3ae684 100644 --- a/code_comments/comment.py +++ b/code_comments/comment.py @@ -70,11 +70,27 @@ def validate(self): def href(self): if self.is_comment_to_file: - href = self.req.href.browser(self.path, rev=self.revision, codecomment=self.id) + href = self.req.href.browser(self.path, rev=self.revision, + codecomment=self.id) elif self.is_comment_to_changeset: href = self.req.href.changeset(self.revision, codecomment=self.id) + base_url = self.env.abs_href() + pathList = base_url.split('/') + projectPath = "" + if len(pathList) > 4: + del pathList[0:3] + projectPath = '/'.join(pathList) + projectPath = '/' + projectPath + if href.startswith(projectPath): + href = href.split("/") + del href[0:len(pathList)+1] + href = '/'.join(href) + href = '/' + href elif self.is_comment_to_attachment: - href = self.req.href('/attachment/ticket/%d/%s' % (self.attachment_ticket, self.attachment_filename), codecomment=self.id) + href = self.req.href('/attachment/ticket/%d/%s' % ( + self.attachment_ticket, + self.attachment_filename), + codecomment=self.id) if self.line and not self.is_comment_to_changeset: href += '#L' + str(self.line) return href diff --git a/code_comments/htdocs/code-comments.js b/code_comments/htdocs/code-comments.js index 2e2ccc4..858f42f 100644 --- a/code_comments/htdocs/code-comments.js +++ b/code_comments/htdocs/code-comments.js @@ -14,7 +14,6 @@ var underscore = _.noConflict(); console.log(traceback); } } - alert(errorText); }); window.Comment = Backbone.Model.extend({ diff --git a/code_comments/subscription.py b/code_comments/subscription.py index 9bba8b0..5e5103a 100644 --- a/code_comments/subscription.py +++ b/code_comments/subscription.py @@ -14,7 +14,6 @@ from code_comments.api import ICodeCommentChangeListener from code_comments.comments import Comments - class Subscription(object): """ Representation of a code comment subscription. @@ -87,11 +86,12 @@ def insert(self, db=None): @self.env.with_transaction() def do_insert(db): cursor = db.cursor() - insert = ("INSERT INTO code_comments_subscriptions " - "(user, type, path, repos, rev, notify) " - "VALUES (%s, %s, %s, %s, %s, %s)") + insert = (u"INSERT INTO code_comments_subscriptions " + u"(user, type, path, repos, rev, notify) " + u"VALUES (%s, %s, %s, %s, %s, %s)") + self.path = self.path.decode('utf8') values = (self.user, self.type, self.path, self.repos, - self.rev, self.notify) + self.rev, self.notify) cursor.execute(insert, values) self.id = db.get_last_id(cursor, 'code_comments_subscriptions') return True @@ -107,9 +107,10 @@ def update(self, db=None): @self.env.with_transaction() def do_update(db): cursor = db.cursor() - update = ("UPDATE code_comments_subscriptions SET " - "user=%s, type=%s, path=%s, repos=%s, rev=%s, " - "notify=%s WHERE id=%s") + update = (u"UPDATE code_comments_subscriptions SET " + u"user=%s, type=%s, path=%s, repos=%s, rev=%s, " + u"notify=%s WHERE id=%s") + self.path = self.path.encode('utf8') values = (self.user, self.type, self.path, self.repos, self.rev, self.notify, self.id) try: @@ -131,6 +132,8 @@ def do_delete(db): "id=%s") cursor.execute(delete, (self.id,)) + + @classmethod def _from_row(cls, env, row): """ @@ -193,10 +196,14 @@ def from_attachment(cls, env, attachment, user=None, notify=True): """ Creates a subscription from an Attachment object. """ - _path = "/{0}/{1}/{2}".format(attachment.parent_realm, + + filename = attachment.filename + + _path = u"/{0}/{1}/{2}".format(attachment.parent_realm, attachment.parent_id, - attachment.filename) - + filename) + _path = _path.encode('utf8') + sub = { 'user': user or attachment.author, 'type': 'attachment', @@ -265,10 +272,13 @@ def for_attachment(cls, env, attachment, path=None, notify=None): Returns all subscriptions for an attachment. The path can be overridden. """ - path_template = "/{0}/{1}/{2}" + path_template = u"/{0}/{1}/{2}" + filename = attachment.filename _path = path or path_template.format(attachment.parent_realm, attachment.parent_id, - attachment.filename) + filename) + _path = _path.encode('utf8') + args = { 'type': 'attachment', 'path': _path, @@ -418,13 +428,17 @@ def attachment_deleted(self, attachment): def attachment_reparented(self, attachment, old_parent_realm, old_parent_id): - path_template = "/{0}/{1}/{2}" + path_template = u"/{0}/{1}/{2}" + filename = attachment.filename old_path = path_template.format(old_parent_realm, old_parent_id, - attachment.filename) + filename) + old_path = old_path.encode('utf8') + new_path = path_template.format(attachment.parent_realm, attachment.parent_id, - attachment.filename) + filename) + new_path = new_path.encode('utf8') for subscription in Subscription.for_attachment(self.env, attachment, old_path):