annotate rhodecode/controllers/admin/repos.py @ 2375:bc2d8c03c050 beta

Implemented #467 Journal logs comments on changesets - added created/updated user action to journal - added created/updated users group action journal - added ip adresses to most of action_log calls to track IP changes - rewrote action_parser to simpler and more efficient solution
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 03 Jun 2012 00:40:14 +0200
parents a21eab6ff42f
children 91fae60bf2b6 9492ab68331f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
824
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
1 # -*- coding: utf-8 -*-
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
2 """
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
3 rhodecode.controllers.admin.repos
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
5
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
6 Repositories controller for RhodeCode
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
7
824
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
8 :created_on: Apr 7, 2010
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
9 :author: marcink
1824
89efedac4e6c 2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
824
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
11 :license: GPLv3, see COPYING for more details.
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
12 """
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
13 # This program is free software: you can redistribute it and/or modify
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
14 # it under the terms of the GNU General Public License as published by
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
15 # the Free Software Foundation, either version 3 of the License, or
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
16 # (at your option) any later version.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
17 #
252
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 248
diff changeset
18 # This program is distributed in the hope that it will be useful,
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 248
diff changeset
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 248
diff changeset
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 248
diff changeset
21 # GNU General Public License for more details.
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
22 #
252
3782a6d698af licensing updates, code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 248
diff changeset
23 # You should have received a copy of the GNU General Public License
1206
a671db5bdd58 fixed license issue #149
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
824
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
25
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
26 import logging
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
27 import traceback
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
28 import formencode
318
fdf9f6ee5217 Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 299
diff changeset
29 from formencode import htmlfill
824
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
30
376
7fbf81447c6c Fixes #18, removing user, who owns some repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 371
diff changeset
31 from paste.httpexceptions import HTTPInternalServerError
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
32 from pylons import request, session, tmpl_context as c, url
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
33 from pylons.controllers.util import redirect
248
fb7f066126cc Added support for repository located in subdirectories.
Marcin Kuzminski <marcin@python-works.com>
parents: 247
diff changeset
34 from pylons.i18n.translation import _
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
35 from sqlalchemy.exc import IntegrityError
824
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
36
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
37 from rhodecode.lib import helpers as h
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
38 from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \
1828
7531c69ebdfc fixes issue when owner of a repo couldn't revoke permissions for users and groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
39 HasPermissionAnyDecorator, HasRepoPermissionAllDecorator
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
40 from rhodecode.lib.base import BaseController, render
1022
4f834b0abcd3 Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents: 1015
diff changeset
41 from rhodecode.lib.utils import invalidate_cache, action_logger, repo_name_slug
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
42 from rhodecode.lib.helpers import get_token
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
43 from rhodecode.model.meta import Session
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1594
diff changeset
44 from rhodecode.model.db import User, Repository, UserFollowing, RepoGroup
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 537
diff changeset
45 from rhodecode.model.forms import RepoForm
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 665
diff changeset
46 from rhodecode.model.scm import ScmModel
629
7e536d1af60d Code refactoring,models renames
Marcin Kuzminski <marcin@python-works.com>
parents: 604
diff changeset
47 from rhodecode.model.repo import RepoModel
824
ceb9f419b7fe some extra fixes added docs string
Marcin Kuzminski <marcin@python-works.com>
parents: 821
diff changeset
48
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
49 log = logging.getLogger(__name__)
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
50
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
51
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
52 class ReposController(BaseController):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
53 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
54 REST Controller styled on the Atom Publishing Protocol"""
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
55 # To properly map this controller, ensure your config/routing.py
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
56 # file has a resource setup:
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
57 # map.resource('repo', 'repos')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
58
235
fcab58c43ea1 Fixed access to repos and users.
Marcin Kuzminski <marcin@python-works.com>
parents: 220
diff changeset
59 @LoginRequired()
417
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 399
diff changeset
60 @HasPermissionAnyDecorator('hg.admin', 'hg.create.repository')
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
61 def __before__(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
62 c.admin_user = session.get('admin_user')
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
63 c.admin_username = session.get('admin_username')
191
b68b2246e5a6 Authenticated controller with LoginRequired decorator, and cleaned __before__ (used in baseController now). fixed User for clone url with logged in session user.
Marcin Kuzminski <marcin@python-works.com>
parents: 169
diff changeset
64 super(ReposController, self).__before__()
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
65
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
66 def __load_defaults(self):
1633
2c0d35e336b5 refactoring of models names for repoGroup permissions
Marcin Kuzminski <marcin@python-works.com>
parents: 1594
diff changeset
67 c.repo_groups = RepoGroup.groups_choices()
1547
fbc762ae3496 unified generation of repo groups choices
Marcin Kuzminski <marcin@python-works.com>
parents: 1539
diff changeset
68 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
69
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
70 repo_model = RepoModel()
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
71 c.users_array = repo_model.get_users_js()
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
72 c.users_groups_array = repo_model.get_users_groups_js()
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
73
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
74 def __load_data(self, repo_name=None):
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
75 """
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
76 Load defaults settings for edit, and update
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
77
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
78 :param repo_name:
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
79 """
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
80 self.__load_defaults()
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
81
1530
04027bdb876c Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
82 c.repo_info = db_repo = Repository.get_by_repo_name(repo_name)
1561
4d841e565237 added validation of params on settings table
Marcin Kuzminski <marcin@python-works.com>
parents: 1547
diff changeset
83 repo = db_repo.scm_instance
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
84
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
85 if c.repo_info is None:
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
86 h.flash(_('%s repository is not mapped to db perhaps'
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
87 ' it was created or renamed from the filesystem'
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
88 ' please run the application again'
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
89 ' in order to rescan repositories') % repo_name,
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
90 category='error')
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
91
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
92 return redirect(url('repos'))
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
93
1530
04027bdb876c Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
94 c.default_user_id = User.get_by_username('default').user_id
1594
9dae92a65e40 fixes #288
Marcin Kuzminski <marcin@python-works.com>
parents: 1561
diff changeset
95 c.in_public_journal = UserFollowing.query()\
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
96 .filter(UserFollowing.user_id == c.default_user_id)\
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
97 .filter(UserFollowing.follows_repository == c.repo_info).scalar()
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
98
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
99 if c.repo_info.stats:
1807
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
100 # this is on what revision we ended up so we add +1 for count
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
101 last_rev = c.repo_info.stats.stat_on_revision + 1
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
102 else:
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
103 last_rev = 0
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
104 c.stats_revision = last_rev
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
105
1807
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
106 c.repo_last_rev = repo.count() if repo.revisions else 0
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
107
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
108 if last_rev == 0 or c.repo_last_rev == 0:
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
109 c.stats_percentage = 0
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
110 else:
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
111 c.stats_percentage = '%.2f' % ((float((last_rev)) /
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
112 c.repo_last_rev) * 100)
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
113
1594
9dae92a65e40 fixes #288
Marcin Kuzminski <marcin@python-works.com>
parents: 1561
diff changeset
114 defaults = RepoModel()._get_defaults(repo_name)
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1807
diff changeset
115
1755
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
116 c.repos_list = [('', _('--REMOVE FORK--'))]
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
117 c.repos_list += [(x.repo_id, x.repo_name) for x in
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
118 Repository.query().order_by(Repository.repo_name).all()]
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
119 return defaults
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
120
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
121 @HasPermissionAllDecorator('hg.admin')
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
122 def index(self, format='html'):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
123 """GET /repos: All items in the collection"""
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
124 # url('repos')
1344
eef7a1b953e8 Admin view will see repos_groups in main list
Marcin Kuzminski <marcin@python-works.com>
parents: 1323
diff changeset
125
1366
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1361
diff changeset
126 c.repos_list = ScmModel().get_repos(Repository.query()
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1361
diff changeset
127 .order_by(Repository.repo_name)
9c0f5d558789 fixes #200, rewrote the whole caching mechanism to get rid of such problems. Now cached instances are attached
Marcin Kuzminski <marcin@python-works.com>
parents: 1361
diff changeset
128 .all(), sort_key='name_sort')
127
20dc7a5eb748 Html changes and cleanups, made folders for html templates, implemented tags and branches pages
Marcin Kuzminski <marcin@python-works.com>
parents: 101
diff changeset
129 return render('admin/repos/repos.html')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
130
417
3ed2d46a2ca7 permission refactoring,
Marcin Kuzminski <marcin@python-works.com>
parents: 399
diff changeset
131 @HasPermissionAnyDecorator('hg.admin', 'hg.create.repository')
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
132 def create(self):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
133 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
134 POST /repos: Create a new item"""
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
135 # url('repos')
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
136
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
137 self.__load_defaults()
357
ebdd1a89cdd9 Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents: 356
diff changeset
138 form_result = {}
215
70f645fa97cc Moved repo creation to admin/repos, as part of crud controller. Now repo creation is based on a form, which can be auto filled with data from 404 page. Fixed the error controller to properly give the repo name.
Marcin Kuzminski <marcin@python-works.com>
parents: 191
diff changeset
139 try:
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
140 form_result = RepoForm(repo_groups=c.repo_groups_choices)()\
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
141 .to_python(dict(request.POST))
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
142 RepoModel().create(form_result, self.rhodecode_user)
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
143 if form_result['clone_uri']:
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
144 h.flash(_('created repository %s from %s') \
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
145 % (form_result['repo_name'], form_result['clone_uri']),
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
146 category='success')
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
147 else:
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
148 h.flash(_('created repository %s') % form_result['repo_name'],
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
149 category='success')
537
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
150
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
151 if request.POST.get('user_created'):
1722
e7eef7a1db6a #235 forking page repo group selection
Marcin Kuzminski <marcin@python-works.com>
parents: 1633
diff changeset
152 # created by regular non admin user
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
153 action_logger(self.rhodecode_user, 'user_created_repo',
2375
bc2d8c03c050 Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 2142
diff changeset
154 form_result['repo_name_full'], self.ip_addr,
bc2d8c03c050 Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 2142
diff changeset
155 self.sa)
537
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
156 else:
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
157 action_logger(self.rhodecode_user, 'admin_created_repo',
2375
bc2d8c03c050 Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 2142
diff changeset
158 form_result['repo_name_full'], self.ip_addr,
bc2d8c03c050 Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 2142
diff changeset
159 self.sa)
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1722
diff changeset
160 Session.commit()
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
161 except formencode.Invalid, errors:
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
162
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
163 c.new_repo = errors.value['repo_name']
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
164
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
165 if request.POST.get('user_created'):
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
166 r = render('admin/repos/repo_add_create_repository.html')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
167 else:
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
168 r = render('admin/repos/repo_add.html')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
169
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
170 return htmlfill.render(
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
171 r,
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
172 defaults=errors.value,
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
173 errors=errors.error_dict or {},
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
174 prefix_error=False,
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
175 encoding="UTF-8")
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
176
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
177 except Exception:
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
178 log.error(traceback.format_exc())
860
5f7731e3ab4d fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents: 832
diff changeset
179 msg = _('error occurred during creation of repository %s') \
357
ebdd1a89cdd9 Added extra validation in creating users.
Marcin Kuzminski <marcin@python-works.com>
parents: 356
diff changeset
180 % form_result.get('repo_name')
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
181 h.flash(msg, category='error')
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
182 if request.POST.get('user_created'):
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
183 return redirect(url('home'))
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
184 return redirect(url('repos'))
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
185
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
186 @HasPermissionAllDecorator('hg.admin')
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
187 def new(self, format='html'):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
188 """GET /repos/new: Form to create a new item"""
215
70f645fa97cc Moved repo creation to admin/repos, as part of crud controller. Now repo creation is based on a form, which can be auto filled with data from 404 page. Fixed the error controller to properly give the repo name.
Marcin Kuzminski <marcin@python-works.com>
parents: 191
diff changeset
189 new_repo = request.GET.get('repo', '')
1022
4f834b0abcd3 Code refactor number 2
Marcin Kuzminski <marcin@python-works.com>
parents: 1015
diff changeset
190 c.new_repo = repo_name_slug(new_repo)
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
191 self.__load_defaults()
215
70f645fa97cc Moved repo creation to admin/repos, as part of crud controller. Now repo creation is based on a form, which can be auto filled with data from 404 page. Fixed the error controller to properly give the repo name.
Marcin Kuzminski <marcin@python-works.com>
parents: 191
diff changeset
192 return render('admin/repos/repo_add.html')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
193
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
194 @HasPermissionAllDecorator('hg.admin')
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
195 def update(self, repo_name):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
196 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
197 PUT /repos/repo_name: Update an existing item"""
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
198 # Forms posted to this method should contain a hidden field:
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
199 # <input type="hidden" name="_method" value="PUT" />
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
200 # Or using helpers:
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
201 # h.form(url('repo', repo_name=ID),
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
202 # method='put')
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
203 # url('repo', repo_name=ID)
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
204 self.__load_defaults()
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
205 repo_model = RepoModel()
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
206 changed_name = repo_name
1245
5f2fbab7c429 PEP8ify - controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 1206
diff changeset
207 _form = RepoForm(edit=True, old_data={'repo_name': repo_name},
1159
187a924ed653 Changes for repo groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1121
diff changeset
208 repo_groups=c.repo_groups_choices)()
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
209 try:
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
210 form_result = _form.to_python(dict(request.POST))
1539
bd604cf75c5a fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
Marcin Kuzminski <marcin@python-works.com>
parents: 1530
diff changeset
211 repo = repo_model.update(repo_name, form_result)
665
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 660
diff changeset
212 invalidate_cache('get_repo_cached_%s' % repo_name)
692
cb0d9ce6ac5c #50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
213 h.flash(_('Repository %s updated successfully' % repo_name),
318
fdf9f6ee5217 Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 299
diff changeset
214 category='success')
1539
bd604cf75c5a fixes #260 Put repo in group, then move group to another group -> repo becomes unavailable
Marcin Kuzminski <marcin@python-works.com>
parents: 1530
diff changeset
215 changed_name = repo.repo_name
660
df61378032f3 #48 rewrote action logger, translated action logger messages, added some extra messages. Linked and showed pushed revisions in logs
Marcin Kuzminski <marcin@python-works.com>
parents: 636
diff changeset
216 action_logger(self.rhodecode_user, 'admin_updated_repo',
2375
bc2d8c03c050 Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 2142
diff changeset
217 changed_name, self.ip_addr, self.sa)
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1722
diff changeset
218 Session.commit()
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
219 except formencode.Invalid, errors:
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
220 defaults = self.__load_data(repo_name)
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
221 defaults.update(errors.value)
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
222 return htmlfill.render(
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
223 render('admin/repos/repo_edit.html'),
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
224 defaults=defaults,
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
225 errors=errors.error_dict or {},
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
226 prefix_error=False,
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
227 encoding="UTF-8")
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
228
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
229 except Exception:
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
230 log.error(traceback.format_exc())
692
cb0d9ce6ac5c #50 on point cache invalidation changes.
Marcin Kuzminski <marcin@python-works.com>
parents: 691
diff changeset
231 h.flash(_('error occurred during update of repository %s') \
356
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
232 % repo_name, category='error')
b0715a788432 Added new style error display,
Marcin Kuzminski <marcin@python-works.com>
parents: 323
diff changeset
233 return redirect(url('edit_repo', repo_name=changed_name))
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
234
380
ca54622e39a1 Added separate create repository views for non administrative users.
Marcin Kuzminski <marcin@python-works.com>
parents: 376
diff changeset
235 @HasPermissionAllDecorator('hg.admin')
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
236 def delete(self, repo_name):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
237 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
238 DELETE /repos/repo_name: Delete an existing item"""
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
239 # Forms posted to this method should contain a hidden field:
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
240 # <input type="hidden" name="_method" value="DELETE" />
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
241 # Or using helpers:
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
242 # h.form(url('repo', repo_name=ID),
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
243 # method='delete')
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
244 # url('repo', repo_name=ID)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
245
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
246 repo_model = RepoModel()
735
dbec976d9975 added action loggers to following repositories,
Marcin Kuzminski <marcin@python-works.com>
parents: 711
diff changeset
247 repo = repo_model.get_by_repo_name(repo_name)
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
248 if not repo:
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
249 h.flash(_('%s repository is not mapped to db perhaps'
266
32d6c955218c added check for repo created outside of hg app
Marcin Kuzminski <marcin@python-works.com>
parents: 265
diff changeset
250 ' it was moved or renamed from the filesystem'
32d6c955218c added check for repo created outside of hg app
Marcin Kuzminski <marcin@python-works.com>
parents: 265
diff changeset
251 ' please run the application again'
318
fdf9f6ee5217 Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 299
diff changeset
252 ' in order to rescan repositories') % repo_name,
fdf9f6ee5217 Implemented permissions into hg app, secured admin controllers, templates and repository specific controllers
Marcin Kuzminski <marcin@python-works.com>
parents: 299
diff changeset
253 category='error')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
254
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
255 return redirect(url('repos'))
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
256 try:
564
ba7e24cd4786 refactor codes and setup for python 2.5
Marcin Kuzminski <marcin@python-works.com>
parents: 548
diff changeset
257 action_logger(self.rhodecode_user, 'admin_deleted_repo',
2375
bc2d8c03c050 Implemented #467 Journal logs comments on changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 2142
diff changeset
258 repo_name, self.ip_addr, self.sa)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
259 repo_model.delete(repo)
665
070f32743632 Moved out reposcan into hg Model.
Marcin Kuzminski <marcin@python-works.com>
parents: 660
diff changeset
260 invalidate_cache('get_repo_cached_%s' % repo_name)
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
261 h.flash(_('deleted repository %s') % repo_name, category='success')
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1722
diff changeset
262 Session.commit()
1361
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
263 except IntegrityError, e:
1752
f28dc032adf0 Added handling of ignore whitespace flag in changesets
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
264 if e.message.find('repositories_fork_id_fkey') != -1:
1361
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
265 log.error(traceback.format_exc())
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
266 h.flash(_('Cannot delete %s it still contains attached '
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
267 'forks') % repo_name,
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
268 category='warning')
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
269 else:
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
270 log.error(traceback.format_exc())
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
271 h.flash(_('An error occurred during '
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
272 'deletion of %s') % repo_name,
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
273 category='error')
87ca17540603 fixed #47 adding a new repo that have a group chosen had wrong paths.
Marcin Kuzminski <marcin@python-works.com>
parents: 1345
diff changeset
274
537
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
275 except Exception, e:
48be953851fc extended user logs to create/delete/fork repositories for auditing
Marcin Kuzminski <marcin@python-works.com>
parents: 417
diff changeset
276 log.error(traceback.format_exc())
860
5f7731e3ab4d fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents: 832
diff changeset
277 h.flash(_('An error occurred during deletion of %s') % repo_name,
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
278 category='error')
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
279
58
8fb1abd4178a Added hg model,implemented removal of repos, added HgModel for fetching repos(with generator)
Marcin Kuzminski <marcin@python-blog.com>
parents: 52
diff changeset
280 return redirect(url('repos'))
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
281
1869
682057a38cd3 white space cleanup
Marcin Kuzminski <marcin@python-works.com>
parents: 1828
diff changeset
282 @HasRepoPermissionAllDecorator('repository.admin')
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
283 def delete_perm_user(self, repo_name):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
284 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
285 DELETE an existing repository permission user
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
286
604
5cc96df705b9 fixed @repo into :repo for docs
Marcin Kuzminski <marcin@python-works.com>
parents: 564
diff changeset
287 :param repo_name:
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
288 """
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
289 try:
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
290 RepoModel().revoke_user_permission(repo=repo_name,
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
291 user=request.POST['user_id'])
1807
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
292 Session.commit()
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
293 except Exception:
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
294 log.error(traceback.format_exc())
860
5f7731e3ab4d fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents: 832
diff changeset
295 h.flash(_('An error occurred during deletion of repository user'),
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
296 category='error')
365
ec7b76d4bda4 Added initial query skipp when seting up the app.
Marcin Kuzminski <marcin@python-works.com>
parents: 357
diff changeset
297 raise HTTPInternalServerError()
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
298
1828
7531c69ebdfc fixes issue when owner of a repo couldn't revoke permissions for users and groups
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
299 @HasRepoPermissionAllDecorator('repository.admin')
1015
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
300 def delete_perm_users_group(self, repo_name):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
301 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
302 DELETE an existing repository permission users group
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
303
1015
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
304 :param repo_name:
708
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
305 """
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
306
1015
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
307 try:
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
308 RepoModel().revoke_users_group_permission(
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
309 repo=repo_name, group_name=request.POST['users_group_id']
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
310 )
1807
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
311 Session.commit()
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
312 except Exception:
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
313 log.error(traceback.format_exc())
1015
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
314 h.flash(_('An error occurred during deletion of repository'
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
315 ' users groups'),
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
316 category='error')
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
317 raise HTTPInternalServerError()
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
318
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
319 @HasPermissionAllDecorator('hg.admin')
65129c332d37 #56 added ajax removal of users groups,
Marcin Kuzminski <marcin@python-works.com>
parents: 1012
diff changeset
320 def repo_stats(self, repo_name):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
321 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
322 DELETE an existing repository statistics
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
323
708
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
324 :param repo_name:
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
325 """
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
326
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
327 try:
1982
87f0800abc7b #227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents: 1869
diff changeset
328 RepoModel().delete_stats(repo_name)
1807
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
329 Session.commit()
708
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
330 except Exception, e:
860
5f7731e3ab4d fixed spelling mistakes, and some minor docs bugs
Marcin Kuzminski <marcin@python-works.com>
parents: 832
diff changeset
331 h.flash(_('An error occurred during deletion of repository stats'),
708
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
332 category='error')
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
333 return redirect(url('edit_repo', repo_name=repo_name))
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
334
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
335 @HasPermissionAllDecorator('hg.admin')
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
336 def repo_cache(self, repo_name):
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
337 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
338 INVALIDATE existing repository cache
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
339
708
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
340 :param repo_name:
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
341 """
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
342
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
343 try:
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
344 ScmModel().mark_for_invalidation(repo_name)
1807
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
345 Session.commit()
708
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
346 except Exception, e:
711
cda88b3eb09c fixed error for empty revisions on admin repo edit
Marcin Kuzminski <marcin@python-works.com>
parents: 708
diff changeset
347 h.flash(_('An error occurred during cache invalidation'),
708
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
348 category='error')
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
349 return redirect(url('edit_repo', repo_name=repo_name))
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
350
b9bbc0d6e9f3 added cache reset, stats reset, and delete into repository settings in admin.
Marcin Kuzminski <marcin@python-works.com>
parents: 692
diff changeset
351 @HasPermissionAllDecorator('hg.admin')
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
352 def repo_public_journal(self, repo_name):
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
353 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
354 Set's this repository to be visible in public journal,
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
355 in other words assing default user to follow this repo
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
356
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
357 :param repo_name:
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
358 """
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
359
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
360 cur_token = request.POST.get('auth_token')
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
361 token = get_token()
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
362 if cur_token == token:
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
363 try:
1530
04027bdb876c Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
364 repo_id = Repository.get_by_repo_name(repo_name).repo_id
04027bdb876c Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents: 1366
diff changeset
365 user_id = User.get_by_username('default').user_id
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
366 self.scm_model.toggle_following_repo(repo_id, user_id)
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
367 h.flash(_('Updated repository visibility in public journal'),
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
368 category='success')
1807
1635a21485d6 - fixed issue with missing commits on some repos commands
Marcin Kuzminski <marcin@python-works.com>
parents: 1755
diff changeset
369 Session.commit()
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
370 except:
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
371 h.flash(_('An error occurred during setting this'
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
372 ' repository in public journal'),
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
373 category='error')
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
374
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
375 else:
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
376 h.flash(_('Token mismatch'), category='error')
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
377 return redirect(url('edit_repo', repo_name=repo_name))
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
378
1114
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
379 @HasPermissionAllDecorator('hg.admin')
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
380 def repo_pull(self, repo_name):
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
381 """
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
382 Runs task to update given repository with remote changes,
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
383 ie. make pull on remote location
1203
6832ef664673 source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents: 1161
diff changeset
384
1114
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
385 :param repo_name:
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
386 """
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
387 try:
1121
f3f847712f87 replaced all global calls to template context (rhodecode_user), into instance attributes
Marcin Kuzminski <marcin@python-works.com>
parents: 1114
diff changeset
388 ScmModel().pull_changes(repo_name, self.rhodecode_user.username)
1114
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
389 h.flash(_('Pulled from remote location'), category='success')
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
390 except Exception, e:
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
391 h.flash(_('An error occurred during pull from remote location'),
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
392 category='error')
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
393
1114
4de3fa6290a7 #109, added manual pull of changes for repositories that have remote location filled in.
Marcin Kuzminski <marcin@python-works.com>
parents: 1112
diff changeset
394 return redirect(url('edit_repo', repo_name=repo_name))
1085
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
395
3fe3285868d1 implemented public journal for anonymous users, admin can control which repositories
Marcin Kuzminski <marcin@python-works.com>
parents: 1082
diff changeset
396 @HasPermissionAllDecorator('hg.admin')
1755
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
397 def repo_as_fork(self, repo_name):
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
398 """
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
399 Mark given repository as a fork of another
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1807
diff changeset
400
1755
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
401 :param repo_name:
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
402 """
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
403 try:
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
404 fork_id = request.POST.get('id_fork_of')
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
405 repo = ScmModel().mark_as_fork(repo_name, fork_id,
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
406 self.rhodecode_user.username)
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
407 fork = repo.fork.repo_name if repo.fork else _('Nothing')
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
408 Session.commit()
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1807
diff changeset
409 h.flash(_('Marked repo %s as fork of %s' % (repo_name,fork)),
1755
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
410 category='success')
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
411 except Exception, e:
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
412 raise
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
413 h.flash(_('An error occurred during this operation'),
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
414 category='error')
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
415
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
416 return redirect(url('edit_repo', repo_name=repo_name))
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
417
1088ded6e602 implements #239 manual marking of repos as forks for admins
Marcin Kuzminski <marcin@python-works.com>
parents: 1752
diff changeset
418 @HasPermissionAllDecorator('hg.admin')
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
419 def show(self, repo_name, format='html'):
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
420 """GET /repos/repo_name: Show a specific item"""
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
421 # url('repo', repo_name=ID)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
422
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
423 @HasPermissionAllDecorator('hg.admin')
299
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
424 def edit(self, repo_name, format='html'):
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
425 """GET /repos/repo_name/edit: Form to edit an existing item"""
d303aacb3349 repos crud controllers - change id into repo_name for compatability, added ajax repo perm user function variuos html fixes, permissions forms and managment fixes.
Marcin Kuzminski <marcin@python-works.com>
parents: 298
diff changeset
426 # url('edit_repo', repo_name=ID)
1112
6d0a7284949d #109, added optional clone uri when creating repo.
Marcin Kuzminski <marcin@python-works.com>
parents: 1106
diff changeset
427 defaults = self.__load_data(repo_name)
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
428
265
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
429 return htmlfill.render(
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
430 render('admin/repos/repo_edit.html'),
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
431 defaults=defaults,
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
432 encoding="UTF-8",
0e5455fda8fd Implemented basic repository managment. Implemented repo2db mappings, model, helpers updates and code cleanups
Marcin Kuzminski <marcin@python-works.com>
parents: 252
diff changeset
433 force_defaults=False
636
ffd07396d315 Fixes for raw_id, needed for git
Marcin Kuzminski <marcin@python-works.com>
parents: 629
diff changeset
434 )