diff --git a/media/css/main.css b/media/css/main.css index 19a0a14..36e1287 100644 --- a/media/css/main.css +++ b/media/css/main.css @@ -29,7 +29,33 @@ td { } tr:hover { - background: #eee; + background: #fafafa; +} + +table.form { + margin: 0; + padding: 0; +} + +table.form th { + width: 6em; + text-align: right; + vertical-align: top; +} + +table.form td { + border: none; +} + +form { + padding: 1ex; + border: 1px #eee solid; +} + +form p { + text-align: right; + margin: 0; + padding: 0; } pre { @@ -39,6 +65,14 @@ pre { padding: 0.5ex; } +input,textarea,select { + border: 1px #888 solid; +} + +textarea { + width: 100%; +} + h1 { margin: 0; padding: 0.5ex; diff --git a/mgmt/templatetags/prj_filters.py b/mgmt/templatetags/prj_filters.py index 0001ed6..16ac137 100644 --- a/mgmt/templatetags/prj_filters.py +++ b/mgmt/templatetags/prj_filters.py @@ -1,3 +1,4 @@ +#encoding: utf-8 import markdown as MD from django import template @@ -14,3 +15,31 @@ def link(obj,type='projects'): @register.filter def markdown(value): return MD.markdown(value,extensions=['codehilite'],safe_mode='escape') + + +class FormNode(template.Node): + def __init__(self,obj,add=''): + self.obj = obj + self.add = add + + def render(self,context): + if self.add: + self.add = self.add[1:-1] + return u"""<form action='.' method='post'> +<table class='form'> +%s +</table> +%s +<p><input type='submit' value='Отправить' /></p> +</form>""" % (context[self.obj].as_table(),self.add) + +@register.tag +def form(parser,token): + cs = token.split_contents() + l = len(cs) + if l == 2: + return FormNode(cs[1],'') + if l == 3: + return FormNode(cs[1],cs[2]) + msg = "`form` tag syntax: {\% form form-object [additional-fields] \%}" + raise template.TemplateSyntaxError(msg) diff --git a/mgmt/views.py b/mgmt/views.py index c9d5728..f33c41f 100644 --- a/mgmt/views.py +++ b/mgmt/views.py @@ -180,7 +180,6 @@ def edit_document(request,doc): if request.method=='POST': name = request.POST['name'] text = request.POST['text'] - doc = Document.objects.get(pk=id) doc.name = name doc.text = text doc.save() diff --git a/templates/base.html b/templates/base.html index 48e2383..119fef1 100644 --- a/templates/base.html +++ b/templates/base.html @@ -7,27 +7,26 @@ </title> <meta name='author' content='Portnov'> {% block head %} - <link rel='stylesheet' type='text/css' href='/media/css/main.css'/> <link rel="stylesheet" type="text/css" href="/media/js/markitup/skins/markitup/style.css" /> <link rel="stylesheet" type="text/css" href="/media/js/markitup/sets/default/style.css" /> + <script type="text/javascript" src="/medja/js/jquery.js"></script> + <script type="text/javascript" src="/medja/js/markitup/jquery.markitup.js"></script> + <script type="text/javascript" src="/media/js/markitup/sets/default/set.js"></script> {% endblock %} </head> <body> - <script type="text/javascript" src="/medja/js/jquery.js"/> - <script type="text/javascript" src="/medja/js/markitup/jquery.markitup.js"/> - <script type="text/javascript" src="/media/js/markitup/sets/default/set.js"/> - <script type="text/javascript" event='window.onload'> $(document).ready(function() { $("textarea").markItUp(mySettings); }); </script> + <div id='body'> <div id='header'> {%block header%} - <h1>Управление проектами</h1> + <h1><a href='/'>Управление проектами</a></h1> {% if menu %} <ul class='menu'> {% for item in menu %} diff --git a/templates/bug.html b/templates/bug.html index f02ada5..b8ccf6f 100644 --- a/templates/bug.html +++ b/templates/bug.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load prj_filters %} {% block title %}Баг: {{bug.name}}{% endblock %} @@ -7,11 +8,7 @@ {% if change_state %} <h3>Сменить состояние бага</h3> -<form action='.' method='post'> - {{change_state.as_p}} - <input type='hidden' name='action' value='change_state'/> - <input type='submit'/> -</form> +{% form change_state "<input type='hidden' name='action' value='change_state'/>" %} {% endif %} {% include "comments.html" %} diff --git a/templates/comments.html b/templates/comments.html index a224e08..09fa148 100644 --- a/templates/comments.html +++ b/templates/comments.html @@ -18,9 +18,5 @@ {% if form %} <h3>Отправить комментарий</h3> -<form method='post' action='.'> - {{ form.as_p }} - <input type='hidden' name='action' value='comment'/> - <input type='submit' /> -</form> +{% form form "<input type='hidden' name='action' value='comment'/>" %} {% endif %} diff --git a/templates/create_doc.html b/templates/create_doc.html index 8437f7d..47fde7b 100644 --- a/templates/create_doc.html +++ b/templates/create_doc.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load prj_filters %} {%block title%}Создать страницу документации{%endblock%} @@ -12,10 +13,7 @@ {% endif %} {% if form %} -<form method='post' action='.'> - {{form.as_p}} - <input type='submit'/> -</form> + {% form form %} {% else %} <p>Вы не можете создавать документацию.</p> {% endif %} diff --git a/templates/edit_bug.html b/templates/edit_bug.html index 2441571..ab924a5 100644 --- a/templates/edit_bug.html +++ b/templates/edit_bug.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load prj_filters %} {% block title %}Редактировать баг #{{bug.id}}{% endblock %} @@ -7,9 +8,6 @@ <h2>Редактировать баг #{{bug.id}}</h2> <div class='links'><a href='{% url mgmt.views.one_bug bug.id %}'>Посмотреть</a></div> -<form action='.' method='post'> - {{form.as_p}} - <input type='submit'/> -</form> +{% form form %} {% endblock %} diff --git a/templates/edit_document.html b/templates/edit_document.html index 7ca3c3b..a934d94 100644 --- a/templates/edit_document.html +++ b/templates/edit_document.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load prj_filters %} {% block title %}Редактировать документ: {{document.name}}{% endblock %} @@ -9,9 +10,6 @@ <a href='{% url mgmt.views.one_document document.id %}'>Посмотреть</a> </div> -<form method='post' action='.'> - {{form.as_p}} - <input type='submit'/> -</form> +{% form form %} {% endblock %} diff --git a/templates/project_bugs.html b/templates/project_bugs.html index 902938e..074c6a4 100644 --- a/templates/project_bugs.html +++ b/templates/project_bugs.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% load prj_filters %} {% block title %}Баги проекта {{project.name}} {% endblock %} @@ -20,10 +21,7 @@ {% if form %} <h3>Отправить баг:</h3> - <form method='post' action='.'> - {{form.as_p}} - <input type='submit'/> - </form> + {% form form %} {% endif %} {% endblock %} diff --git a/templates/user_page.html b/templates/user_page.html index f7faa91..78ca4ad 100644 --- a/templates/user_page.html +++ b/templates/user_page.html @@ -8,10 +8,7 @@ {% if form %} <h3>Отправить сообщение</h3> - <form action='.' method='post'> - {{form.as_p}} - <input type='submit'/> - </form> + {% form form %} {% else %} <h3>Сообщения</h3> <table>