##// END OF EJS Templates
unified generation of repo groups choices...
marcink -
r1547:fbc762ae beta
parent child Browse files
Show More
@@ -64,20 +64,10 b' class ReposController(BaseController):'
64 64 super(ReposController, self).__before__()
65 65
66 66 def __load_defaults(self):
67 repo_model = RepoModel()
67 c.repo_groups = Group.groups_choices()
68 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
68 69
69 c.repo_groups = [('', '')]
70 parents_link = lambda k: h.literal('»'.join(
71 map(lambda k: k.group_name,
72 k.parents + [k])
73 )
74 )
75
76 c.repo_groups.extend([(x.group_id, parents_link(x)) for \
77 x in self.sa.query(Group).all()])
78 c.repo_groups = sorted(c.repo_groups,
79 key=lambda t: t[1].split('»')[0])
80 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
70 repo_model = RepoModel()
81 71 c.users_array = repo_model.get_users_js()
82 72 c.users_groups_array = repo_model.get_users_groups_js()
83 73
@@ -32,15 +32,7 b' class ReposGroupsController(BaseControll'
32 32 super(ReposGroupsController, self).__before__()
33 33
34 34 def __load_defaults(self):
35
36 c.repo_groups = [('', '')]
37 parents_link = lambda k: h.literal('»'.join(k))
38
39 c.repo_groups.extend([(x.group_id, parents_link(x.full_path_splitted))
40 for x in self.sa.query(Group).all()])
41
42 c.repo_groups = sorted(c.repo_groups,
43 key=lambda t: t[1].split('»')[0])
35 c.repo_groups = Group.groups_choices()
44 36 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
45 37
46 38 def __load_data(self, group_id):
@@ -366,17 +366,7 b' class SettingsController(BaseController)'
366 366 def create_repository(self):
367 367 """GET /_admin/create_repository: Form to create a new item"""
368 368
369 c.repo_groups = [('', '')]
370 parents_link = lambda k: h.literal('»'.join(
371 map(lambda k: k.group_name,
372 k.parents + [k])
373 )
374 )
375
376 c.repo_groups.extend([(x.group_id, parents_link(x)) for \
377 x in self.sa.query(Group).all()])
378 c.repo_groups = sorted(c.repo_groups,
379 key=lambda t: t[1].split('»')[0])
369 c.repo_groups = Group.groups_choices()
380 370 c.repo_groups_choices = map(lambda k: unicode(k[0]), c.repo_groups)
381 371
382 372 new_repo = request.GET.get('repo', '')
@@ -598,12 +598,11 b' def repo_link(groups_and_repos):'
598 598 return repo_name
599 599 else:
600 600 def make_link(group):
601 return link_to(group.group_name, url('repos_group',
602 id=group.group_id))
601 return link_to(group.name, url('repos_group_home',
602 group_name=group.group_name))
603 603 return literal(' » '.join(map(make_link, groups)) + \
604 604 " » " + repo_name)
605 605
606
607 606 def fancy_file_stats(stats):
608 607 """
609 608 Displays a fancy two colored bar for number of added/deleted
@@ -389,6 +389,11 b' def repo2db_mapper(initial_repo_list, re'
389 389 rm = RepoModel()
390 390 user = sa.query(User).filter(User.admin == True).first()
391 391 added = []
392 # fixup groups paths to new format on the fly
393 # TODO: remove this in future
394 for g in Group.query().all():
395 g.group_name = g.get_new_name(g.name)
396 sa.add(g)
392 397 for name, repo in initial_repo_list.items():
393 398 group = map_groups(name.split(os.sep))
394 399 if not rm.get_by_repo_name(name, cache=False):
@@ -744,6 +744,19 b' class Group(Base, BaseModel):'
744 744 self.group_name)
745 745
746 746 @classmethod
747 def groups_choices(cls):
748 from webhelpers.html import literal as _literal
749 repo_groups = [('', '')]
750 sep = ' » '
751 _name = lambda k: _literal(sep.join(k))
752
753 repo_groups.extend([(x.group_id, _name(x.full_path_splitted))
754 for x in cls.query().all()])
755
756 repo_groups = sorted(repo_groups,key=lambda t: t[1].split(sep)[0])
757 return repo_groups
758
759 @classmethod
747 760 def url_sep(cls):
748 761 return '/'
749 762
@@ -45,17 +45,17 b''
45 45
46 46 ##REPO TYPE
47 47 %if c.dbrepo.repo_type =='hg':
48 <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url("/images/icons/hgicon.png")}"/>
48 <img style="margin-bottom:2px" class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
49 49 %endif
50 50 %if c.dbrepo.repo_type =='git':
51 <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url("/images/icons/giticon.png")}"/>
51 <img style="margin-bottom:2px" class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
52 52 %endif
53 53
54 54 ##PUBLIC/PRIVATE
55 55 %if c.dbrepo.private:
56 <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url("/images/icons/lock.png")}"/>
56 <img style="margin-bottom:2px" class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/>
57 57 %else:
58 <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url("/images/icons/lock_open.png")}"/>
58 <img style="margin-bottom:2px" class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/>
59 59 %endif
60 60
61 61 ##REPO NAME
@@ -67,7 +67,7 b''
67 67 <a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}">
68 68 <img class="icon" alt="${_('public')}"
69 69 title="${_('Fork of')} ${c.dbrepo.fork.repo_name}"
70 src="${h.url("/images/icons/arrow_divide.png")}"/>
70 src="${h.url('/images/icons/arrow_divide.png')}"/>
71 71 ${_('Fork of')} ${c.dbrepo.fork.repo_name}
72 72 </a>
73 73 </div>
@@ -78,7 +78,7 b''
78 78 <a href="${h.url(str(h.hide_credentials(c.dbrepo.clone_uri)))}">
79 79 <img class="icon" alt="${_('remote clone')}"
80 80 title="${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}"
81 src="${h.url("/images/icons/connect.png")}"/>
81 src="${h.url('/images/icons/connect.png')}"/>
82 82 ${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}
83 83 </a>
84 84 </div>
General Comments 0
You need to be logged in to leave comments. Login now