Show More
@@ -44,6 +44,7 b' from rhodecode.model.db import User, Rep' | |||||
44 | from rhodecode.model.forms import RepoForm |
|
44 | from rhodecode.model.forms import RepoForm | |
45 | from rhodecode.model.scm import ScmModel |
|
45 | from rhodecode.model.scm import ScmModel | |
46 | from rhodecode.model.repo import RepoModel |
|
46 | from rhodecode.model.repo import RepoModel | |
|
47 | from sqlalchemy.exc import IntegrityError | |||
47 |
|
48 | |||
48 | log = logging.getLogger(__name__) |
|
49 | log = logging.getLogger(__name__) | |
49 |
|
50 | |||
@@ -179,11 +180,12 b' class ReposController(BaseController):' | |||||
179 | category='success') |
|
180 | category='success') | |
180 |
|
181 | |||
181 | if request.POST.get('user_created'): |
|
182 | if request.POST.get('user_created'): | |
|
183 | #created by regular non admin user | |||
182 | action_logger(self.rhodecode_user, 'user_created_repo', |
|
184 | action_logger(self.rhodecode_user, 'user_created_repo', | |
183 | form_result['repo_name'], '', self.sa) |
|
185 | form_result['repo_name_full'], '', self.sa) | |
184 | else: |
|
186 | else: | |
185 | action_logger(self.rhodecode_user, 'admin_created_repo', |
|
187 | action_logger(self.rhodecode_user, 'admin_created_repo', | |
186 | form_result['repo_name'], '', self.sa) |
|
188 | form_result['repo_name_full'], '', self.sa) | |
187 |
|
189 | |||
188 | except formencode.Invalid, errors: |
|
190 | except formencode.Invalid, errors: | |
189 |
|
191 | |||
@@ -287,6 +289,18 b' class ReposController(BaseController):' | |||||
287 | invalidate_cache('get_repo_cached_%s' % repo_name) |
|
289 | invalidate_cache('get_repo_cached_%s' % repo_name) | |
288 | h.flash(_('deleted repository %s') % repo_name, category='success') |
|
290 | h.flash(_('deleted repository %s') % repo_name, category='success') | |
289 |
|
291 | |||
|
292 | except IntegrityError, e: | |||
|
293 | if e.message.find('repositories_fork_id_fkey'): | |||
|
294 | log.error(traceback.format_exc()) | |||
|
295 | h.flash(_('Cannot delete %s it still contains attached ' | |||
|
296 | 'forks') % repo_name, | |||
|
297 | category='warning') | |||
|
298 | else: | |||
|
299 | log.error(traceback.format_exc()) | |||
|
300 | h.flash(_('An error occurred during ' | |||
|
301 | 'deletion of %s') % repo_name, | |||
|
302 | category='error') | |||
|
303 | ||||
290 | except Exception, e: |
|
304 | except Exception, e: | |
291 | log.error(traceback.format_exc()) |
|
305 | log.error(traceback.format_exc()) | |
292 | h.flash(_('An error occurred during deletion of %s') % repo_name, |
|
306 | h.flash(_('An error occurred during deletion of %s') % repo_name, |
@@ -386,6 +386,7 b' def repo2db_mapper(initial_repo_list, re' | |||||
386 | added.append(name) |
|
386 | added.append(name) | |
387 | form_data = { |
|
387 | form_data = { | |
388 | 'repo_name': name, |
|
388 | 'repo_name': name, | |
|
389 | 'repo_name_full': name, | |||
389 | 'repo_type': repo.alias, |
|
390 | 'repo_type': repo.alias, | |
390 | 'description': repo.description \ |
|
391 | 'description': repo.description \ | |
391 | if repo.description != 'unknown' else \ |
|
392 | if repo.description != 'unknown' else \ |
@@ -227,8 +227,7 b' class ValidRepoUser(formencode.validator' | |||||
227 |
|
227 | |||
228 | def to_python(self, value, state): |
|
228 | def to_python(self, value, state): | |
229 | try: |
|
229 | try: | |
230 | self.user_db = User.query()\ |
|
230 | User.query().filter(User.active == True)\ | |
231 | .filter(User.active == True)\ |
|
|||
232 | .filter(User.username == value).one() |
|
231 | .filter(User.username == value).one() | |
233 | except Exception: |
|
232 | except Exception: | |
234 | raise formencode.Invalid(_('This username is not valid'), |
|
233 | raise formencode.Invalid(_('This username is not valid'), | |
@@ -251,7 +250,8 b' def ValidRepoName(edit, old_data):' | |||||
251 | gr = Group.get(value.get('repo_group')) |
|
250 | gr = Group.get(value.get('repo_group')) | |
252 | group_path = gr.full_path |
|
251 | group_path = gr.full_path | |
253 | # value needs to be aware of group name in order to check |
|
252 | # value needs to be aware of group name in order to check | |
254 | # db key |
|
253 | # db key This is an actuall just the name to store in the | |
|
254 | # database | |||
255 | repo_name_full = group_path + Group.url_sep() + repo_name |
|
255 | repo_name_full = group_path + Group.url_sep() + repo_name | |
256 | else: |
|
256 | else: | |
257 | group_path = '' |
|
257 | group_path = '' |
@@ -198,14 +198,17 b' class RepoModel(BaseModel):' | |||||
198 | #force str since hg doesn't go with unicode |
|
198 | #force str since hg doesn't go with unicode | |
199 | repo_name = str(form_data['fork_name']) |
|
199 | repo_name = str(form_data['fork_name']) | |
200 | org_name = str(form_data['repo_name']) |
|
200 | org_name = str(form_data['repo_name']) | |
|
201 | org_full_name = str(form_data['repo_name_full']) | |||
201 |
|
202 | |||
202 | else: |
|
203 | else: | |
203 | org_name = repo_name = str(form_data['repo_name']) |
|
204 | org_name = repo_name = str(form_data['repo_name']) | |
|
205 | repo_name_full = form_data['repo_name_full'] | |||
|
206 | ||||
204 | new_repo = Repository() |
|
207 | new_repo = Repository() | |
205 | new_repo.enable_statistics = False |
|
208 | new_repo.enable_statistics = False | |
206 | for k, v in form_data.items(): |
|
209 | for k, v in form_data.items(): | |
207 | if k == 'repo_name': |
|
210 | if k == 'repo_name': | |
208 | v = repo_name |
|
211 | v = repo_name_full | |
209 | if k == 'repo_group': |
|
212 | if k == 'repo_group': | |
210 | k = 'group_id' |
|
213 | k = 'group_id' | |
211 |
|
214 | |||
@@ -213,7 +216,7 b' class RepoModel(BaseModel):' | |||||
213 |
|
216 | |||
214 | if fork: |
|
217 | if fork: | |
215 | parent_repo = self.sa.query(Repository)\ |
|
218 | parent_repo = self.sa.query(Repository)\ | |
216 | .filter(Repository.repo_name == org_name).scalar() |
|
219 | .filter(Repository.repo_name == org_full_name).scalar() | |
217 | new_repo.fork = parent_repo |
|
220 | new_repo.fork = parent_repo | |
218 |
|
221 | |||
219 | new_repo.user_id = cur_user.user_id |
|
222 | new_repo.user_id = cur_user.user_id | |
@@ -309,7 +312,9 b' class RepoModel(BaseModel):' | |||||
309 |
|
312 | |||
310 | def __create_repo(self, repo_name, alias, new_parent_id, clone_uri=False): |
|
313 | def __create_repo(self, repo_name, alias, new_parent_id, clone_uri=False): | |
311 | """ |
|
314 | """ | |
312 |
makes repository on filesystem |
|
315 | makes repository on filesystem. It's group aware means it'll create | |
|
316 | a repository within a group, and alter the paths accordingly of | |||
|
317 | group location | |||
313 |
|
318 | |||
314 | :param repo_name: |
|
319 | :param repo_name: | |
315 | :param alias: |
|
320 | :param alias: |
General Comments 0
You need to be logged in to leave comments.
Login now