allura
リビジョン | 8abe8ac669f8af706807175f1d5ceb52d93e281f (tree) |
---|---|
日時 | 2012-05-17 05:07:38 |
作者 | Cory Johns <johnsca@geek...> |
コミッター | Cory Johns |
[#2886] Some small label, test and default value touch-ups
Signed-off-by: Cory Johns <johnsca@geek.net>
@@ -62,7 +62,7 @@ class RepoRootController(BaseController): | ||
62 | 62 | |
63 | 63 | @with_trailing_slash |
64 | 64 | @expose('jinja:allura:templates/repo/fork.html') |
65 | - def fork(self, to_name=None, project_id=None, mount_label=None): | |
65 | + def fork(self, project_id=None, mount_point=None, mount_label=None): | |
66 | 66 | # this shows the form and handles the submission |
67 | 67 | security.require_authenticated() |
68 | 68 | if not c.app.forkable: raise exc.HTTPNotFound |
@@ -71,16 +71,12 @@ class RepoRootController(BaseController): | ||
71 | 71 | ThreadLocalORMSession.close_all() |
72 | 72 | from_project = c.project |
73 | 73 | to_project = M.Project.query.get(_id=ObjectId(project_id)) |
74 | - mount_label = mount_label or '%s - Code' % c.project.name | |
75 | - try: | |
76 | - to_name = (to_name or | |
77 | - re.search('[a-z]+$', from_project.shortname).group(0)) | |
78 | - except AttributeError: | |
79 | - to_name = '' | |
80 | - if request.method != 'POST' or not to_name: | |
74 | + mount_label = mount_label or '%s - %s' % (c.project.name, from_repo.tool_name) | |
75 | + mount_point = (mount_point or from_project.shortname) | |
76 | + if request.method != 'POST' or not mount_point: | |
81 | 77 | return dict(from_repo=from_repo, |
82 | 78 | user_project=c.user.private_project(), |
83 | - to_name=to_name, | |
79 | + mount_point=mount_point, | |
84 | 80 | mount_label=mount_label) |
85 | 81 | else: |
86 | 82 | with h.push_config(c, project=to_project): |
@@ -90,11 +86,11 @@ class RepoRootController(BaseController): | ||
90 | 86 | try: |
91 | 87 | to_project.install_app( |
92 | 88 | ep_name=from_repo.tool_name, |
93 | - mount_point=to_name, | |
89 | + mount_point=mount_point, | |
94 | 90 | mount_label=mount_label, |
95 | 91 | cloned_from_project_id=from_project._id, |
96 | 92 | cloned_from_repo_id=from_repo._id) |
97 | - redirect(to_project.url()+to_name+'/') | |
93 | + redirect(to_project.url()+mount_point+'/') | |
98 | 94 | except exc.HTTPRedirection: |
99 | 95 | raise |
100 | 96 | except Exception, ex: |
@@ -16,13 +16,13 @@ | ||
16 | 16 | {% endfor %} |
17 | 17 | </select> |
18 | 18 | </div> |
19 | - <label class="grid-4">Repository Name:</label> | |
19 | + <label class="grid-4" for="mount_label">Label:</label> | |
20 | 20 | <div class="grid-15"> |
21 | - <input type="text" name="to_name" value="{{to_name}}"/> | |
21 | + <input type="text" name="mount_label" value="{{mount_label}}"/> | |
22 | 22 | </div> |
23 | - <label class="grid-4" for="mount_label">Mount label:</label> | |
23 | + <label class="grid-4">Mount point:</label> | |
24 | 24 | <div class="grid-15"> |
25 | - <input type="text" name="mount_label" value="{{mount_label}}"/> | |
25 | + <input type="text" name="mount_point" value="{{mount_point}}"/> | |
26 | 26 | </div> |
27 | 27 | <label class="grid-4"> </label> |
28 | 28 | <div class="grid-15"> |
@@ -38,23 +38,23 @@ class TestRootController(TestController): | ||
38 | 38 | |
39 | 39 | def test_fork(self): |
40 | 40 | r = self.app.get('%sfork/' % c.app.repo.url()) |
41 | - assert '<input type="text" name="to_name" value="test"/>' in r | |
42 | - assert '<input type="text" name="mount_label" value="test - Code"/>' \ | |
43 | - in r | |
41 | + assert '<input type="text" name="mount_point" value="test"/>' in r | |
42 | + assert '<input type="text" name="mount_label" value="test - Git"/>' in r | |
44 | 43 | |
45 | 44 | to_project = M.Project.query.get(shortname='test2', neighborhood_id=c.project.neighborhood_id) |
46 | - to_name = 'reponame' | |
45 | + mount_point = 'reponame' | |
47 | 46 | r = self.app.post('/src-git/fork', params=dict( |
48 | 47 | project_id=str(to_project._id), |
49 | - to_name=to_name, | |
48 | + mount_point=mount_point, | |
50 | 49 | mount_label='Test forked repository')) |
50 | + assert "{status: 'error'}" not in str(r.follow()) | |
51 | 51 | cloned_from = c.app.repo |
52 | - with h.push_context('test2', to_name, neighborhood='Projects'): | |
52 | + with h.push_context('test2', mount_point, neighborhood='Projects'): | |
53 | 53 | c.app.repo.init_as_clone( |
54 | 54 | cloned_from.full_fs_path, |
55 | 55 | cloned_from.app.config.script_name(), |
56 | 56 | cloned_from.full_fs_path) |
57 | - r = self.app.get('/p/test2/%s' % to_name).follow().follow().follow() | |
57 | + r = self.app.get('/p/test2/%s' % mount_point).follow().follow().follow() | |
58 | 58 | assert 'Clone of' in r |
59 | 59 | assert 'Test forked repository' in r |
60 | 60 | r = self.app.get('/src-git/').follow().follow() |
@@ -64,7 +64,7 @@ class TestRootController(TestController): | ||
64 | 64 | to_project = M.Project.query.get(shortname='test2', neighborhood_id=c.project.neighborhood_id) |
65 | 65 | r = self.app.post('/src-git/fork', params=dict( |
66 | 66 | project_id=str(to_project._id), |
67 | - to_name='code')) | |
67 | + mount_point='code')) | |
68 | 68 | cloned_from = c.app.repo |
69 | 69 | with h.push_context('test2', 'code', neighborhood='Projects'): |
70 | 70 | c.app.repo.init_as_clone( |
@@ -1,6 +1,9 @@ | ||
1 | 1 | import json |
2 | 2 | |
3 | 3 | import pkg_resources |
4 | +import pylons | |
5 | +pylons.c = pylons.tmpl_context | |
6 | +pylons.g = pylons.app_globals | |
4 | 7 | from pylons import c |
5 | 8 | from ming.orm import ThreadLocalORMSession |
6 | 9 | from datadiff.tools import assert_equal |
@@ -35,7 +38,8 @@ class TestRootController(TestController): | ||
35 | 38 | to_project = M.Project.query.get(shortname='test2', neighborhood_id=c.project.neighborhood_id) |
36 | 39 | r = self.app.post('/src-hg/fork', params=dict( |
37 | 40 | project_id=str(to_project._id), |
38 | - to_name='code')) | |
41 | + mount_point='code')) | |
42 | + assert "{status: 'error'}" not in str(r.follow()) | |
39 | 43 | cloned_from = c.app.repo |
40 | 44 | with h.push_context('test2', 'code', neighborhood='Projects'): |
41 | 45 | c.app.repo.init_as_clone( |
@@ -51,7 +55,8 @@ class TestRootController(TestController): | ||
51 | 55 | to_project = M.Project.query.get(shortname='test2', neighborhood_id=c.project.neighborhood_id) |
52 | 56 | r = self.app.post('/src-hg/fork', params=dict( |
53 | 57 | project_id=str(to_project._id), |
54 | - to_name='code')) | |
58 | + mount_point='code')) | |
59 | + assert "{status: 'error'}" not in str(r.follow()) | |
55 | 60 | cloned_from = c.app.repo |
56 | 61 | with h.push_context('test2', 'code', neighborhood='Projects'): |
57 | 62 | c.app.repo.init_as_clone( |