diff --git a/mgmt/context.py b/mgmt/context.py
index c3b6d72..1322527 100644
--- a/mgmt/context.py
+++ b/mgmt/context.py
@@ -4,17 +4,13 @@ import sys
from os.path import dirname
import re
-sys.path.append(dirname(dirname(__file__)))
+sys.path.insert(0,dirname(dirname(dirname(__file__))))
import settings
from hms import hms
import debug
from models import *
-show_blocks = dict(
- last_comments = dict(),
- login = dict(hide='/login/$',show_logged=False))
-
def make_chart(path):
p1 = re.compile('/projects/(\d+)/$')
m = p1.match(path)
@@ -39,9 +35,9 @@ def add_blocks(request):
blocks = {}
logged = request.user.is_authenticated()
for blk in hms.generate('block'):
- if blk.name in show_blocks:
+ if blk.name in settings.show_blocks:
show = True
- d = show_blocks[blk.name]
+ d = settings.show_blocks[blk.name]
hre = d.get('hide',None)
if hre:
if re.match(hre,request.path):
diff --git a/mgmt/management.py b/mgmt/management.py
deleted file mode 100644
index 612db9c..0000000
--- a/mgmt/management.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from django.db.models import signals
-from django.dispatch import dispatcher
-
-from models import *;
-
-def after_save(cls=None,instance=None):
- if not cls or not instance:
- return
- if cls in [Project,Bug,Document]:
- obj = Object(type=cls.__name__, oid=instance.id)
- obj.save()
-
-dispatcher.connect(after_save, signal=signals.post_save)
-
diff --git a/mgmt/rights.py b/mgmt/rights.py
index 567f774..d9294a8 100644
--- a/mgmt/rights.py
+++ b/mgmt/rights.py
@@ -1,22 +1,17 @@
import debug
from models import BugState
+from os.path import dirname
+import sys
+sys.path.append(dirname(dirname(__file__)))
+import settings
+
def set_responsible(bug,user):
bug.responsible = user
-bug_rights = {
- (1,2): ('Team',None),
- (1,5): ('Admin',None),
- (2,1): ('Admin',None),
- (2,3): ('Team', set_responsible),
- (2,5): ('Admin',None),
- (3,4): ('Team',None),
- (4,5): ('Team',None),
- (5,1): ('Team',None) }
-
def can_change_bug_state(user,bug,new_state):
- if (bug.status.id,new_state) in bug_rights:
- cat,proc = bug_rights[(bug.status.id,new_state)]
+ if (bug.status.id,new_state) in settings.bug_rights:
+ cat = settings.bug_rights[(bug.status.id,new_state)]
if cat=='Team':
return user in bug.project.team.iterator()
if cat=='Admin':
diff --git a/mgmt/views.py b/mgmt/views.py
index 3310fa3..6a95a7a 100644
--- a/mgmt/views.py
+++ b/mgmt/views.py
@@ -15,7 +15,10 @@ from models import *
from context import add_blocks,debug_messages,add_menu
from rights import can,possible_changes
-COMMENTS_PER_PAGE = 10
+from os.path import dirname
+import sys
+sys.path.append(dirname(dirname(__file__)))
+import settings
def render_it(template,dict,request):
c = RequestContext(request,dict,[add_blocks,add_menu,debug_messages])
@@ -37,7 +40,7 @@ class DocForm(forms.Form):
def get_comments(request,id,type):
all = Comment.objects.filter(object_id=id, object_type=type)
- pg = Paginator(all,COMMENTS_PER_PAGE)
+ pg = Paginator(all,settings.COMMENTS_PER_PAGE)
page_num = int(request.GET.get('page',1))
page = pg.page(page_num)
range = pg.page_range
diff --git a/pygit/chart.py b/pygit/chart.py
index 94f3beb..310e277 100644
--- a/pygit/chart.py
+++ b/pygit/chart.py
@@ -2,7 +2,7 @@
from os.path import exists
import cairo
-width,height = 600,100
+width,height = 900,150
pl,pr,py = 10,30,17
root = "/home/portnov/www/projects/"
@@ -28,11 +28,11 @@ def make_chart(labels,dataset,colors,out_path):
step_x = float(width-pl-pr)/n
surf = cairo.ImageSurface(cairo.FORMAT_ARGB32,width,height)
cx = cairo.Context(surf)
+ M = max(map(max,dataset))
for i in range(len(dataset)):
data = dataset[i]
color = colors[i]
- M = max(data)
scale_y = float(height-2*py)/M
make_one_chart(data,color,cx,step_x,scale_y)
diff --git a/pygit/pygit.py b/pygit/pygit.py
index 62e5b08..8b0d229 100644
--- a/pygit/pygit.py
+++ b/pygit/pygit.py
@@ -47,7 +47,7 @@ def date(tp):
def commits(rid,branch='master'):
r = open_repo(rid)
- cs = r.commits(branch)[:20]
+ cs = r.commits(branch)
return [(c.id_abbrev,date(c.authored_date),c.author.name,c.message) for c in cs]
def root_tree(rid,branch='master'):
@@ -135,7 +135,7 @@ def stats_sum(lst):
r = {'lines': 0, 'files': 0}
for cm in lst:
try:
- r['lines'] += cm.stats.total['lines']
+ r['lines'] += float(cm.stats.total['lines'])/5
r['files'] += cm.stats.total['files']
except ValueError:
pass
@@ -143,10 +143,10 @@ def stats_sum(lst):
def commits_stats(rid,branch='master'):
r = open_repo(rid)
- d = r.commits(branch,max_count=100)
+ d = r.commits(branch,max_count=200)
grp = group_by_date(d)
dates = [g[0] for g in grp]
- n_commits = [len(g[1]) for g in grp]
+ n_commits = [len(g[1])*2 for g in grp]
stats = [stats_sum(g[1]) for g in grp]
files = [s['files'] for s in stats]
lines = [s['lines'] for s in stats]
diff --git a/settings.py b/settings.py
index b5e7bff..9e3c2bb 100644
--- a/settings.py
+++ b/settings.py
@@ -1,4 +1,5 @@
# Django settings for projects project.
+# encoding: utf-8
DEBUG = True
TEMPLATE_DEBUG = DEBUG
@@ -83,3 +84,26 @@ INSTALLED_APPS = (
'django.contrib.sites',
'projects.mgmt',
)
+
+show_blocks = dict(
+ last_comments = dict(),
+ login = dict(hide='/login/$',show_logged=False))
+
+bug_rights = {
+ (1,2): 'Team',
+ (1,5): 'Admin',
+ (2,1): 'Admin',
+ (2,3): 'Team',
+ (2,5): 'Admin',
+ (3,4): 'Team',
+ (4,5): 'Team',
+ (5,1): 'Team'}
+
+COMMENTS_PER_PAGE = 10
+
+MENU_ANONYMOUS = [(u'Главная','/'),
+ (u'Вход','/login/')]
+
+MENU_USER = [(u'Главная','/'),
+ (u'Git', '/git'),
+ (u'Выход', '/logout/')]
diff --git a/templates/repo.html b/templates/repo.html
index 75193d2..f79f90f 100644
--- a/templates/repo.html
+++ b/templates/repo.html
@@ -21,7 +21,8 @@
<table>
{% for id,dt,author,message in commits %}
<tr>
- <td><a href='{% url pygit.views.diff_all rid,current_branch,id %}'>{{id}}</a></td><td>{{dt}}</td><td>{{author}}</td><td>{{message}}</td>
+ <td><a href='{% url pygit.views.diff_all rid,current_branch,id %}'>{{id}}</a></td>
+ <td>{{dt}}</td><td>{{author}}</td><td>{{message}}</td>
</tr>
{% endfor %}
</table>