##// END OF EJS Templates
implements #239 manual marking of repos as forks for admins
marcink -
r1755:1088ded6 beta
parent child Browse files
Show More
@@ -116,19 +116,21 b' def make_map(config):'
116 116
117 117 #settings actions
118 118 m.connect('repo_stats', "/repos_stats/{repo_name:.*}",
119 action="repo_stats", conditions=dict(method=["DELETE"],
120 function=check_repo))
119 action="repo_stats", conditions=dict(method=["DELETE"],
120 function=check_repo))
121 121 m.connect('repo_cache', "/repos_cache/{repo_name:.*}",
122 action="repo_cache", conditions=dict(method=["DELETE"],
122 action="repo_cache", conditions=dict(method=["DELETE"],
123 function=check_repo))
124 m.connect('repo_public_journal',"/repos_public_journal/{repo_name:.*}",
125 action="repo_public_journal", conditions=dict(method=["PUT"],
123 126 function=check_repo))
124 m.connect('repo_public_journal',
125 "/repos_public_journal/{repo_name:.*}",
126 action="repo_public_journal", conditions=dict(method=["PUT"],
127 function=check_repo))
128 127 m.connect('repo_pull', "/repo_pull/{repo_name:.*}",
129 action="repo_pull", conditions=dict(method=["PUT"],
130 function=check_repo))
131
128 action="repo_pull", conditions=dict(method=["PUT"],
129 function=check_repo))
130 m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*}",
131 action="repo_as_fork", conditions=dict(method=["PUT"],
132 function=check_repo))
133
132 134 with rmap.submapper(path_prefix=ADMIN_PREFIX,
133 135 controller='admin/repos_groups') as m:
134 136 m.connect("repos_groups", "/repos_groups",
@@ -111,6 +111,10 b' class ReposController(BaseController):'
111 111 c.repo_last_rev) * 100)
112 112
113 113 defaults = RepoModel()._get_defaults(repo_name)
114
115 c.repos_list = [('', _('--REMOVE FORK--'))]
116 c.repos_list += [(x.repo_id, x.repo_name) for x in
117 Repository.query().order_by(Repository.repo_name).all()]
114 118 return defaults
115 119
116 120 @HasPermissionAllDecorator('hg.admin')
@@ -380,6 +384,28 b' class ReposController(BaseController):'
380 384 return redirect(url('edit_repo', repo_name=repo_name))
381 385
382 386 @HasPermissionAllDecorator('hg.admin')
387 def repo_as_fork(self, repo_name):
388 """
389 Mark given repository as a fork of another
390
391 :param repo_name:
392 """
393 try:
394 fork_id = request.POST.get('id_fork_of')
395 repo = ScmModel().mark_as_fork(repo_name, fork_id,
396 self.rhodecode_user.username)
397 fork = repo.fork.repo_name if repo.fork else _('Nothing')
398 Session.commit()
399 h.flash(_('Marked repo %s as fork of %s' % (repo_name,fork)),
400 category='success')
401 except Exception, e:
402 raise
403 h.flash(_('An error occurred during this operation'),
404 category='error')
405
406 return redirect(url('edit_repo', repo_name=repo_name))
407
408 @HasPermissionAllDecorator('hg.admin')
383 409 def show(self, repo_name, format='html'):
384 410 """GET /repos/repo_name: Show a specific item"""
385 411 # url('repo', repo_name=ID)
@@ -89,5 +89,4 b' class BaseModel(object):'
89 89 else:
90 90 if instance:
91 91 raise Exception('given object must be int or Instance'
92 ' of %s got %s' % (type(cls),
93 type(instance)))
92 ' of %s got %s' % (type(cls), type(instance)))
@@ -117,6 +117,18 b' class ScmModel(BaseModel):'
117 117 Generic Scm Model
118 118 """
119 119
120 def __get_repo(self, instance):
121 cls = Repository
122 if isinstance(instance, cls):
123 return instance
124 elif isinstance(instance, int) or str(instance).isdigit():
125 return cls.get(instance)
126 elif isinstance(instance, basestring):
127 return cls.get_by_repo_name(instance)
128 elif instance:
129 raise Exception('given object must be int, basestr or Instance'
130 ' of %s got %s' % (type(cls), type(instance)))
131
120 132 @LazyProperty
121 133 def repos_path(self):
122 134 """
@@ -279,6 +291,13 b' class ScmModel(BaseModel):'
279 291 return self.sa.query(Repository)\
280 292 .filter(Repository.fork_id == repo_id).count()
281 293
294 def mark_as_fork(self, repo, fork, user):
295 repo = self.__get_repo(repo)
296 fork = self.__get_repo(fork)
297 repo.fork = fork
298 self.sa.add(repo)
299 return repo
300
282 301 def pull_changes(self, repo_name, username):
283 302 dbrepo = Repository.get_by_repo_name(repo_name)
284 303 clone_uri = dbrepo.clone_uri
@@ -131,14 +131,13 b''
131 131 ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
132 132 <div class="form">
133 133 <div class="fields">
134 ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="refresh_icon action_button",onclick="return confirm('"+_('Confirm to remove current statistics')+"');")}
135 <div class="field" style="border:none">
134 ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="ui-btn",onclick="return confirm('"+_('Confirm to remove current statistics')+"');")}
135 <div class="field" style="border:none;color:#888">
136 136 <ul>
137 137 <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
138 138 <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
139 139 </ul>
140 140 </div>
141
142 141 </div>
143 142 </div>
144 143 ${h.end_form()}
@@ -148,7 +147,7 b''
148 147 ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')}
149 148 <div class="form">
150 149 <div class="fields">
151 ${h.submit('remote_pull_%s' % c.repo_info.repo_name,_('Pull changes from remote location'),class_="pull_icon action_button",onclick="return confirm('"+_('Confirm to pull changes from remote side')+"');")}
150 ${h.submit('remote_pull_%s' % c.repo_info.repo_name,_('Pull changes from remote location'),class_="ui-btn",onclick="return confirm('"+_('Confirm to pull changes from remote side')+"');")}
152 151 <div class="field" style="border:none">
153 152 <ul>
154 153 <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li>
@@ -163,7 +162,7 b''
163 162 ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
164 163 <div class="form">
165 164 <div class="fields">
166 ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="refresh_icon action_button",onclick="return confirm('"+_('Confirm to invalidate repository cache')+"');")}
165 ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="ui-btn",onclick="return confirm('"+_('Confirm to invalidate repository cache')+"');")}
167 166 </div>
168 167 </div>
169 168 ${h.end_form()}
@@ -171,14 +170,20 b''
171 170 <h3>${_('Public journal')}</h3>
172 171 ${h.form(url('repo_public_journal', repo_name=c.repo_info.repo_name),method='put')}
173 172 <div class="form">
174 <div class="fields">
175 173 ${h.hidden('auth_token',str(h.get_token()))}
174 <div class="field">
176 175 %if c.in_public_journal:
177 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="stop_following_icon action_button")}
176 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="ui-btn")}
178 177 %else:
179 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="start_following_icon action_button")}
178 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="ui-btn")}
180 179 %endif
181 </div>
180 </div>
181 <div class="field" style="border:none;color:#888">
182 <ul>
183 <li>${_('''All actions made on this repository will be accessible to everyone in public journal''')}
184 </li>
185 </ul>
186 </div>
182 187 </div>
183 188 ${h.end_form()}
184 189
@@ -186,8 +191,30 b''
186 191 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')}
187 192 <div class="form">
188 193 <div class="fields">
189 ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="delete_icon action_button",onclick="return confirm('"+_('Confirm to delete this repository')+"');")}
194 ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this repository')+"');")}
190 195 </div>
196 <div class="field" style="border:none;color:#888">
197 <ul>
198 <li>${_('''This repository will be renamed in a special way in order to be unaccesible for RhodeCode and VCS systems.
199 If you need fully delete it from filesystem please do it manually''')}
200 </li>
201 </ul>
202 </div>
203 </div>
204 ${h.end_form()}
205
206 <h3>${_('Set as fork')}</h3>
207 ${h.form(url('repo_as_fork', repo_name=c.repo_info.repo_name),method='put')}
208 <div class="form">
209 <div class="fields">
210 ${h.select('id_fork_of','',c.repos_list,class_="medium")}
211 ${h.submit('set_as_fork_%s' % c.repo_info.repo_name,_('set'),class_="ui-btn",)}
212 </div>
213 <div class="field" style="border:none;color:#888">
214 <ul>
215 <li>${_('''Manually set this repository as a fork of another''')}</li>
216 </ul>
217 </div>
191 218 </div>
192 219 ${h.end_form()}
193 220
General Comments 0
You need to be logged in to leave comments. Login now