diff options
author | Stephen Finucane <stephen.finucane@intel.com> | 2016-02-06 20:32:20 +0000 |
---|---|---|
committer | Stephen Finucane <stephen.finucane@intel.com> | 2016-03-16 09:37:39 +0000 |
commit | ef56359fb7762126edac213d36727f4e0655f9f8 (patch) | |
tree | c5984eb84c319345388ece4c2edb8d6f204c3b86 /patchwork/templatetags | |
parent | 2aab573703741a481952bd9f3301574de44c172f (diff) | |
download | patchwork-ef56359fb7762126edac213d36727f4e0655f9f8.tar patchwork-ef56359fb7762126edac213d36727f4e0655f9f8.tar.gz |
models: Merge patch and first comment
At the moment a patch is split into two model entries: a Patch and a
linked Comment. The original rationale for this was that a Patch is
really a sub-class of Comment. A comment is a record of the text
content of an incoming mail, while a patch is that, plus the patch
content too. Hence the separation and a one-to-one relationship when a
patch is present. However, this decision was made before Django added
support for model inheritance and is no longer necessary. This change
flatten the models in preparation for some email subclassing work. This
is achieved by copying over the non-duplicated fields from the Comment
to the linked Patch, then deleting the Comment.
The migrations are broken into two steps: a schema migration and a data
migration, per the recommendations of the Django documentation [1]. SQL
migration scripts, where necessary, will need to be created manually as
there appears to be no way to do this in a way that is
RDBMS-independant [2][3].
[1] https://docs.djangoproject.com/en/1.9/topics/migrations/#data-migrations
[2] https://stackoverflow.com/q/6856849/
[3] https://stackoverflow.com/q/224732/
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Diffstat (limited to 'patchwork/templatetags')
-rw-r--r-- | patchwork/templatetags/syntax.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/patchwork/templatetags/syntax.py b/patchwork/templatetags/syntax.py index 2a4164d..85ed201 100644 --- a/patchwork/templatetags/syntax.py +++ b/patchwork/templatetags/syntax.py @@ -59,23 +59,23 @@ _span = '<span class="%s">%s</span>' @register.filter def patchsyntax(patch): - content = escape(patch.content).replace('\r\n', '\n') + diff = escape(patch.diff).replace('\r\n', '\n') for (r, cls) in _patch_span_res: - content = r.sub(lambda x: _span % (cls, x.group(0)), content) + diff = r.sub(lambda x: _span % (cls, x.group(0)), diff) - content = _patch_chunk_re.sub( + diff = _patch_chunk_re.sub( lambda x: _span % ('p_chunk', x.group(1)) + ' ' + _span % ('p_context', x.group(2)), - content) + diff) - return mark_safe(content) + return mark_safe(diff) @register.filter -def commentsyntax(comment): - content = escape(comment.content) +def commentsyntax(patch): + content = escape(patch.content) for (r, cls) in _comment_span_res: content = r.sub(lambda x: _span % (cls, x.group(0)), content) |