diff --git a/rhodecode/__init__.py b/rhodecode/__init__.py --- a/rhodecode/__init__.py +++ b/rhodecode/__init__.py @@ -51,7 +51,7 @@ PYRAMID_SETTINGS = {} EXTENSIONS = {} __version__ = ('.'.join((str(each) for each in VERSION[:3]))) -__dbversion__ = 86 # defines current db version for migrations +__dbversion__ = 87 # defines current db version for migrations __platform__ = platform.system() __license__ = 'AGPLv3, and Commercial License' __author__ = 'RhodeCode GmbH' diff --git a/rhodecode/apps/repository/tests/test_repo_pullrequests.py b/rhodecode/apps/repository/tests/test_repo_pullrequests.py --- a/rhodecode/apps/repository/tests/test_repo_pullrequests.py +++ b/rhodecode/apps/repository/tests/test_repo_pullrequests.py @@ -368,8 +368,9 @@ class TestPullrequestsView(object): ('target_repo', target.repo_name), ('target_ref', 'branch:default:' + commit_ids['ancestor']), ('common_ancestor', commit_ids['ancestor']), + ('pullrequest_title', 'Title'), ('pullrequest_desc', 'Description'), - ('pullrequest_title', 'Title'), + ('description_renderer', 'markdown'), ('__start__', 'review_members:sequence'), ('__start__', 'reviewer:mapping'), ('user_id', '1'), @@ -427,8 +428,9 @@ class TestPullrequestsView(object): ('target_repo', target.repo_name), ('target_ref', 'branch:default:' + commit_ids['ancestor-child']), ('common_ancestor', commit_ids['ancestor']), + ('pullrequest_title', 'Title'), ('pullrequest_desc', 'Description'), - ('pullrequest_title', 'Title'), + ('description_renderer', 'markdown'), ('__start__', 'review_members:sequence'), ('__start__', 'reviewer:mapping'), ('user_id', '2'), @@ -493,8 +495,9 @@ class TestPullrequestsView(object): ('target_repo', target.repo_name), ('target_ref', 'branch:default:' + commit_ids['ancestor-child']), ('common_ancestor', commit_ids['ancestor']), + ('pullrequest_title', 'Title'), ('pullrequest_desc', 'Description'), - ('pullrequest_title', 'Title'), + ('description_renderer', 'markdown'), ('__start__', 'review_members:sequence'), ('__start__', 'reviewer:mapping'), ('user_id', '1'), diff --git a/rhodecode/apps/repository/views/repo_pull_requests.py b/rhodecode/apps/repository/views/repo_pull_requests.py --- a/rhodecode/apps/repository/views/repo_pull_requests.py +++ b/rhodecode/apps/repository/views/repo_pull_requests.py @@ -61,7 +61,8 @@ class RepoPullRequestsView(RepoAppView, c = self._get_local_tmpl_context(include_app_defaults=True) c.REVIEW_STATUS_APPROVED = ChangesetStatus.STATUS_APPROVED c.REVIEW_STATUS_REJECTED = ChangesetStatus.STATUS_REJECTED - + # backward compat., we use for OLD PRs a plain renderer + c.renderer = 'plain' return c def _get_pull_requests_list( @@ -297,6 +298,7 @@ class RepoPullRequestsView(RepoAppView, pull_request_at_ver) c.pull_request = pull_request_display_obj + c.renderer = pull_request_at_ver.description_renderer or c.renderer c.pull_request_latest = pull_request_latest if compare or (at_version and not at_version == 'latest'): @@ -894,6 +896,7 @@ class RepoPullRequestsView(RepoAppView, ) description = _form['pullrequest_desc'] + description_renderer = _form['description_renderer'] try: pull_request = PullRequestModel().create( @@ -906,6 +909,7 @@ class RepoPullRequestsView(RepoAppView, reviewers=reviewers, title=pullrequest_title, description=description, + description_renderer=description_renderer, reviewer_data=reviewer_rules, auth_user=self._rhodecode_user ) @@ -970,10 +974,14 @@ class RepoPullRequestsView(RepoAppView, def _edit_pull_request(self, pull_request): _ = self.request.translate + try: PullRequestModel().edit( - pull_request, self.request.POST.get('title'), - self.request.POST.get('description'), self._rhodecode_user) + pull_request, + self.request.POST.get('title'), + self.request.POST.get('description'), + self.request.POST.get('description_renderer'), + self._rhodecode_user) except ValueError: msg = _(u'Cannot update closed pull requests.') h.flash(msg, category='error') diff --git a/rhodecode/lib/dbmigrate/versions/087_version_4_13_0.py b/rhodecode/lib/dbmigrate/versions/087_version_4_13_0.py new file mode 100644 --- /dev/null +++ b/rhodecode/lib/dbmigrate/versions/087_version_4_13_0.py @@ -0,0 +1,40 @@ +import logging + +from sqlalchemy import * + +from rhodecode.model import meta +from rhodecode.lib.dbmigrate.versions import _reset_base, notify + +log = logging.getLogger(__name__) + + +def upgrade(migrate_engine): + """ + Upgrade operations go here. + Don't create your own engine; bind migrate_engine to your metadata + """ + _reset_base(migrate_engine) + from rhodecode.lib.dbmigrate.schema import db_4_11_0_0 as db + + pull_request_table = db.PullRequest.__table__ + pull_request_version_table = db.PullRequestVersion.__table__ + + renderer = Column('description_renderer', Unicode(64), nullable=True) + renderer.create(table=pull_request_table) + + renderer_ver = Column('description_renderer', Unicode(64), nullable=True) + renderer_ver.create(table=pull_request_version_table) + + # issue fixups + fixups(db, meta.Session) + + +def downgrade(migrate_engine): + meta = MetaData() + meta.bind = migrate_engine + + +def fixups(models, _SESSION): + pass + + diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1814,7 +1814,11 @@ def render(source, renderer='rst', menti return relative_links(html_source, relative_urls) return html_source - if renderer == 'rst': + if renderer == 'plain': + return literal( + MarkupRenderer.plain(source, leading_newline=False)) + + elif renderer == 'rst': if repo_name: # process patterns on comments if we pass in repo name source, issues = process_patterns( @@ -1824,6 +1828,7 @@ def render(source, renderer='rst', menti '