diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -417,6 +417,11 @@ def make_map(config): controller='compare', action='index', conditions=dict(function=check_repo)) + rmap.connect('pullrequest_home', + '/{repo_name:.*}/pull-request/new', + controller='pullrequests', action='index', + conditions=dict(function=check_repo)) + rmap.connect('summary_home', '/{repo_name:.*}/summary', controller='summary', conditions=dict(function=check_repo)) diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py new file mode 100644 --- /dev/null +++ b/rhodecode/controllers/pullrequests.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +""" + rhodecode.controllers.pullrequests + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + pull requests controller for rhodecode for initializing pull requests + + :created_on: May 7, 2012 + :author: marcink + :copyright: (C) 2010-2012 Marcin Kuzminski + :license: GPLv3, see COPYING for more details. +""" +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +import logging +import traceback + +from pylons import request, response, session, tmpl_context as c, url +from pylons.controllers.util import abort, redirect +from pylons.i18n.translation import _ + +from rhodecode.lib.base import BaseRepoController, render +from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator +from webob.exc import HTTPNotFound + +log = logging.getLogger(__name__) + + +class PullrequestsController(BaseRepoController): + + @LoginRequired() + @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', + 'repository.admin') + def __before__(self): + super(PullrequestsController, self).__before__() + + def _get_repo_refs(self,repo): + hist_l = [] + + branches_group = ([(k, k) for k in repo.branches.keys()], _("Branches")) + bookmarks_group = ([(k, k) for k in repo.bookmarks.keys()], _("Bookmarks")) + tags_group = ([(k, k) for k in repo.tags.keys()], _("Tags")) + + hist_l.append(bookmarks_group) + hist_l.append(branches_group) + hist_l.append(tags_group) + + return hist_l + + def index(self): + c.org_refs = self._get_repo_refs(c.rhodecode_repo) + c.sources = [] + c.sources.append('%s/%s' % (c.rhodecode_db_repo.user.username, + c.repo_name)) + return render('/pullrequests/pullrequest.html') diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1281,6 +1281,7 @@ class Notification(Base, BaseModel): TYPE_MESSAGE = u'message' TYPE_MENTION = u'mention' TYPE_REGISTRATION = u'registration' + TYPE_PULL_REQUEST = u'pull_request' notification_id = Column('notification_id', Integer(), nullable=False, primary_key=True) subject = Column('subject', Unicode(512), nullable=True) diff --git a/rhodecode/templates/admin/notifications/notifications.html b/rhodecode/templates/admin/notifications/notifications.html --- a/rhodecode/templates/admin/notifications/notifications.html +++ b/rhodecode/templates/admin/notifications/notifications.html @@ -25,6 +25,10 @@ ## %if c.notifications: +
+ ${_('All')} + ${_('Pull requests')} +
${_('Mark all read')}
diff --git a/rhodecode/templates/changelog/changelog.html b/rhodecode/templates/changelog/changelog.html --- a/rhodecode/templates/changelog/changelog.html +++ b/rhodecode/templates/changelog/changelog.html @@ -31,6 +31,7 @@
+
${h.form(h.url.current(),method='get')}
diff --git a/rhodecode/templates/pullrequests/pullrequest.html b/rhodecode/templates/pullrequests/pullrequest.html new file mode 100644 --- /dev/null +++ b/rhodecode/templates/pullrequests/pullrequest.html @@ -0,0 +1,91 @@ +<%inherit file="/base/base.html"/> + +<%def name="title()"> + ${c.repo_name} ${_('Pull request')} + + +<%def name="breadcrumbs_links()"> + ${h.link_to(u'Home',h.url('/'))} + » + ${h.link_to(c.repo_name,h.url('changelog_home',repo_name=c.repo_name))} + » + ${_('Pull request')} + + +<%def name="main()"> + +
+ +
+ ${self.breadcrumbs()} +
+
+ ##ORG +
+
+
+ gravatar +
+ + ${h.select('other','',['%s/%s' % (c.rhodecode_db_repo.user.username,c.repo_name)])}:${h.select('other_ref','',c.org_refs)} + +
${c.rhodecode_db_repo.description}
+
+
+
+
+ +
+ + ##OTHER, most Probably the PARENT OF THIS FORK +
+
+
+ gravatar +
+ + ${h.select('orther','',c.sources)}:${h.select('other_ref','',c.org_refs)} + +
${c.rhodecode_db_repo.description}
+
+
+
+
+ +

${_('New pull request')} from USER:REF into PARENT:REF

+ ${h.form(url('#'),method='put')} +
+ + +
+ +
+
+ +
+
+ ${h.text('pullrequest_title',size=30)} +
+
+ +
+
+ +
+
+ ${h.textarea('pullrequest_desc',size=30)} +
+
+ +
+ ${h.submit('save',_('Send pull request'),class_="ui-button")} + ${h.reset('reset',_('Reset'),class_="ui-button")} +
+
+
+ ${h.end_form()} + + +
+ + diff --git a/rhodecode/templates/repo_switcher_list.html b/rhodecode/templates/repo_switcher_list.html --- a/rhodecode/templates/repo_switcher_list.html +++ b/rhodecode/templates/repo_switcher_list.html @@ -1,7 +1,7 @@ ## -*- coding: utf-8 -*-
  • - +
  • %for repo in c.repos_list: diff --git a/rhodecode/tests/functional/test_pullrequests.py b/rhodecode/tests/functional/test_pullrequests.py new file mode 100644 --- /dev/null +++ b/rhodecode/tests/functional/test_pullrequests.py @@ -0,0 +1,7 @@ +from rhodecode.tests import * + +class TestPullrequestsController(TestController): + + def test_index(self): + response = self.app.get(url(controller='pullrequests', action='index')) + # Test response...