Projects can now be 'open' and 'closed. Guests can view only open projects.
Projects can now be 'open' and 'closed. Guests can view only open projects.
diff --git a/media/css/main.css b/media/css/main.css
index be359a7..e7158c8 100644
--- a/media/css/main.css
+++ b/media/css/main.css
@@ -140,7 +140,19 @@ ul.menu li {
padding-left: 1em;
}
-ul.menu a {
+ul.project-menu {
+ border-bottom: 1px #888 solid;
+ text-align: right;
+ float: right;
+ font-size: small;
+ padding: 0.5ex 1em;
+ margin: 0;
+}
+
+ul.project-menu li {
+ list-style: none;
+ display: inline;
+ padding-left: 1em;
}
ul.errorlist {
@@ -162,13 +174,10 @@ ul.errorlist {
text-align: right;
}
-.project-link a {
-}
-
.project {
+ width: 100%;
border-bottom: 1px #888 solid;
margin-bottom: 2ex;
- overflow: hidden;
}
.block-last_comments ul {
diff --git a/mgmt/models.py b/mgmt/models.py
index d3b5119..d431936 100644
--- a/mgmt/models.py
+++ b/mgmt/models.py
@@ -19,6 +19,7 @@ class Project(Object):
git_link = models.CharField(max_length=32,null=True)
admins = models.ManyToManyField(User,related_name='admin_projects')
team = models.ManyToManyField(User,related_name='in_projects')
+ open = models.BooleanField()
def __unicode__(self):
return self.name
class Meta:
diff --git a/mgmt/project_views.py b/mgmt/project_views.py
index 5d9235d..192710e 100644
--- a/mgmt/project_views.py
+++ b/mgmt/project_views.py
@@ -5,9 +5,9 @@ from models import *
from rights import can
from forms import CommentForm
+@check_auth(Project,'view')
@render_to('project.html')
-def one_project(request,id):
- project = Project.objects.get(pk=id)
+def one_project(request,project):
if request.method=='POST':
title = request.POST['title']
text = request.POST['text']
@@ -33,9 +33,9 @@ def one_project(request,id):
'comments': comments,
'form': form}
+@check_auth(Project,'view')
@render_to('project_bugs.html')
-def project_bugs(request,id):
- project = Project.objects.get(pk=id)
+def project_bugs(request,project):
page,pages,bugs = get_bugs(request,id)
for bug in bugs:
bug.complexity_str = dict(settings.COMPLEXITY_CHOICES).get(bug.complexity,'Unknown')
diff --git a/mgmt/rights.py b/mgmt/rights.py
index 723634a..ce0dd11 100644
--- a/mgmt/rights.py
+++ b/mgmt/rights.py
@@ -21,6 +21,9 @@ def can(user,action,object=None,target=None):
cls = object.__class__.__name__
if action in ['comment','send bug','request']:
return user.is_authenticated()
+ if action == 'view':
+ if cls == 'Project':
+ return object.open or user.is_authenticated()
if action == 'edit':
if cls == 'Project':
return user in object.admins.iterator()
diff --git a/mgmt/utils.py b/mgmt/utils.py
index 70c71b1..59023d6 100644
--- a/mgmt/utils.py
+++ b/mgmt/utils.py
@@ -4,7 +4,7 @@ from django.http import HttpResponse
from django.core.paginator import Paginator
from django.conf import settings
-from context import add_blocks,debug_messages,add_menu,for_rss
+from context import *
from models import *
#############
diff --git a/mgmt/views.py b/mgmt/views.py
index 93fa0ff..4e67684 100644
--- a/mgmt/views.py
+++ b/mgmt/views.py
@@ -29,7 +29,10 @@ from rss_views import *
@render_to('main.html')
def main(request):
- projects = Project.objects.all()
+ if request.user.is_authenticated():
+ projects = Project.objects.all()
+ else:
+ projects = Project.objects.filter(open=True)
return {'projects': projects}
@login_required
diff --git a/templates/base.html b/templates/base.html
index ff80456..ff708ea 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -52,6 +52,14 @@
{% endif %}
<div id='main'>
+ {% if project %}
+ <ul class='project-menu'>
+ <li><a href='{% url mgmt.views.project_documents project.id %}'>Документация</a></li>
+ <li><a href='{% url mgmt.views.project_bugs project.id %}'>Баги</a></li>
+ <li><a href='{% url mgmt.views.requests project.id %}'>Запросы функциональности</a></li>
+ <li><a href='{% url mgmt.views.project_tasks project.id %}'>Задания</a></li>
+ </ul>
+ {% endif %}
{% block main %}{% endblock %}
</div>
diff --git a/templates/project_body.html b/templates/project_body.html
index 883779a..c7b0e82 100644
--- a/templates/project_body.html
+++ b/templates/project_body.html
@@ -7,11 +7,5 @@
{% else %}
{{ project.repo }}
{% endif %}</p>
- <p>{{ project.text|markdown|safe }}</p>
- <p class='links'>
- <a href='{% url mgmt.views.project_documents project.id %}'>Документация</a>
- <a href='{% url mgmt.views.project_bugs project.id %}'>Баги</a>
- <a href='{% url mgmt.views.requests project.id %}'>Запросы функциональности</a>
- <a href='{% url mgmt.views.project_tasks project.id %}'>Задания</a>
- </p>
+ <div>{{ project.text|markdown|safe }}</div>
</div>