##// END OF EJS Templates
fixed sorting of tags and branches. Fix made in vcs.
marcink -
r389:174785aa default
parent child Browse files
Show More
@@ -1,46 +1,47 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3 # branches controller for pylons
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5
5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; version 2
9 9 # of the License or (at your opinion) any later version of the license.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19 # MA 02110-1301, USA.
20 20 """
21 21 Created on April 21, 2010
22 22 branches controller for pylons
23 23 @author: marcink
24 24 """
25 from pylons import tmpl_context as c, request
25 from pylons import tmpl_context as c
26 26 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 27 from pylons_app.lib.base import BaseController, render
28 from pylons_app.lib.utils import OrderedDict
28 29 from pylons_app.model.hg_model import HgModel
29 30 import logging
30 31 log = logging.getLogger(__name__)
31 32
32 33 class BranchesController(BaseController):
33 34
34 35 @LoginRequired()
35 36 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')
36 37 def __before__(self):
37 38 super(BranchesController, self).__before__()
38 39
39 40 def index(self):
40 41 hg_model = HgModel()
41 42 c.repo_info = hg_model.get_repo(c.repo_name)
42 c.repo_branches = {}
43 c.repo_branches = OrderedDict()
43 44 for name, hash_ in c.repo_info.branches.items():
44 45 c.repo_branches[name] = c.repo_info.get_changeset(hash_)
45 46
46 47 return render('branches/branches.html')
@@ -1,121 +1,121 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3 # summary controller for pylons
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5 5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; version 2
9 9 # of the License or (at your opinion) any later version of the license.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19 # MA 02110-1301, USA.
20 20 """
21 21 Created on April 18, 2010
22 22 summary controller for pylons
23 23 @author: marcink
24 24 """
25 25 from datetime import datetime, timedelta
26 26 from pylons import tmpl_context as c, request
27 27 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
28 28 from pylons_app.lib.base import BaseController, render
29 29 from pylons_app.lib.helpers import person
30 30 from pylons_app.lib.utils import OrderedDict
31 31 from pylons_app.model.hg_model import HgModel
32 32 from time import mktime
33 33 from webhelpers.paginate import Page
34 34 import calendar
35 35 import logging
36 36
37 37 log = logging.getLogger(__name__)
38 38
39 39 class SummaryController(BaseController):
40 40
41 41 @LoginRequired()
42 42 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
43 43 'repository.admin')
44 44 def __before__(self):
45 45 super(SummaryController, self).__before__()
46 46
47 47 def index(self):
48 48 hg_model = HgModel()
49 49 c.repo_info = hg_model.get_repo(c.repo_name)
50 50 c.repo_changesets = Page(list(c.repo_info[:10]), page=1, items_per_page=20)
51 51 e = request.environ
52 52 uri = u'%(protocol)s://%(user)s@%(host)s/%(repo_name)s' % {
53 53 'protocol': e.get('wsgi.url_scheme'),
54 54 'user':str(c.hg_app_user.username),
55 55 'host':e.get('HTTP_HOST'),
56 56 'repo_name':c.repo_name, }
57 57 c.clone_repo_url = uri
58 c.repo_tags = {}
58 c.repo_tags = OrderedDict()
59 59 for name, hash in c.repo_info.tags.items()[:10]:
60 60 c.repo_tags[name] = c.repo_info.get_changeset(hash)
61 61
62 c.repo_branches = {}
62 c.repo_branches = OrderedDict()
63 63 for name, hash in c.repo_info.branches.items()[:10]:
64 64 c.repo_branches[name] = c.repo_info.get_changeset(hash)
65 65
66 66 c.commit_data = self.__get_commit_stats(c.repo_info)
67 67
68 68 return render('summary/summary.html')
69 69
70 70
71 71
72 72 def __get_commit_stats(self, repo):
73 73 aggregate = OrderedDict()
74 74
75 75 #graph range
76 76 td = datetime.today()
77 77 y = td.year
78 78 m = td.month
79 79 d = td.day
80 80 c.ts_min = mktime((y, (td - timedelta(days=calendar.mdays[m] - 1)).month, d, 0, 0, 0, 0, 0, 0,))
81 81 c.ts_max = mktime((y, m, d, 0, 0, 0, 0, 0, 0,))
82 82
83 83
84 84 def author_key_cleaner(k):
85 85 k = person(k)
86 86 return k
87 87
88 88 for cs in repo:
89 89 k = '%s-%s-%s' % (cs.date.timetuple()[0], cs.date.timetuple()[1],
90 90 cs.date.timetuple()[2])
91 91 timetupple = [int(x) for x in k.split('-')]
92 92 timetupple.extend([0 for _ in xrange(6)])
93 93 k = mktime(timetupple)
94 94 if aggregate.has_key(author_key_cleaner(cs.author)):
95 95 if aggregate[author_key_cleaner(cs.author)].has_key(k):
96 96 aggregate[author_key_cleaner(cs.author)][k] += 1
97 97 else:
98 98 #aggregate[author_key_cleaner(cs.author)].update(dates_range)
99 99 if k >= c.ts_min and k <= c.ts_max:
100 100 aggregate[author_key_cleaner(cs.author)][k] = 1
101 101 else:
102 102 if k >= c.ts_min and k <= c.ts_max:
103 103 aggregate[author_key_cleaner(cs.author)] = OrderedDict()
104 104 #aggregate[author_key_cleaner(cs.author)].update(dates_range)
105 105 aggregate[author_key_cleaner(cs.author)][k] = 1
106 106
107 107 d = ''
108 108 tmpl0 = u""""%s":%s"""
109 109 tmpl1 = u"""{label:"%s",data:%s},"""
110 110 for author in aggregate:
111 111 d += tmpl0 % (author.decode('utf8'),
112 112 tmpl1 \
113 113 % (author.decode('utf8'),
114 114 [[x, aggregate[author][x]] for x in aggregate[author]]))
115 115 if d == '':
116 116 d = '"%s":{label:"%s",data:[[0,0],]}' \
117 117 % (author_key_cleaner(repo.contact),
118 118 author_key_cleaner(repo.contact))
119 119 return d
120 120
121 121
@@ -1,46 +1,47 b''
1 1 #!/usr/bin/env python
2 2 # encoding: utf-8
3 3 # tags controller for pylons
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5
5 #
6 6 # This program is free software; you can redistribute it and/or
7 7 # modify it under the terms of the GNU General Public License
8 8 # as published by the Free Software Foundation; version 2
9 9 # of the License or (at your opinion) any later version of the license.
10 10 #
11 11 # This program is distributed in the hope that it will be useful,
12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 # GNU General Public License for more details.
15 15 #
16 16 # You should have received a copy of the GNU General Public License
17 17 # along with this program; if not, write to the Free Software
18 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19 # MA 02110-1301, USA.
20 20 """
21 21 Created on April 21, 2010
22 22 tags controller for pylons
23 23 @author: marcink
24 24 """
25 from pylons import tmpl_context as c, request
25 from pylons import tmpl_context as c
26 26 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
27 27 from pylons_app.lib.base import BaseController, render
28 from pylons_app.lib.utils import OrderedDict
28 29 from pylons_app.model.hg_model import HgModel
29 30 import logging
30 31 log = logging.getLogger(__name__)
31 32
32 33 class TagsController(BaseController):
33 34
34 35 @LoginRequired()
35 36 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')
36 37 def __before__(self):
37 38 super(TagsController, self).__before__()
38 39
39 40 def index(self):
40 41 hg_model = HgModel()
41 42 c.repo_info = hg_model.get_repo(c.repo_name)
42 c.repo_tags = {}
43 for name, hash in c.repo_info.tags.items():
44 c.repo_tags[name] = c.repo_info.get_changeset(hash)
43 c.repo_tags = OrderedDict()
44 for name, hash_ in c.repo_info.tags.items():
45 c.repo_tags[name] = c.repo_info.get_changeset(hash_)
45 46
46 47 return render('tags/tags.html')
General Comments 0
You need to be logged in to leave comments. Login now