Browse files

tests pass

  • Loading branch information...
1 parent 75b7283 commit b564e5822d458c68be1f95af7b4cc65bd53eb39b @andreysobol committed Feb 29, 2012
View
0 testsobol/mainapp/templatetags/__init__.py
No changes.
View
19 testsobol/mainapp/templatetags/my_tags.py
@@ -0,0 +1,19 @@
+from django.template import Library, Node, Variable
+from django.core.urlresolvers import reverse
+
+register = Library()
+
+class EditAdmin(Node):
+
+ def __init__(self, edit):
+ self.edit = Variable(edit)
+
+ def render(self, context):
+ e = self.edit.resolve(context)
+ return u'<a href="%s">Edit</a>' % reverse('admin:%s_%s_change' % (e._meta.app_label, e._meta.module_name), args=(e.id,))
+
+
+def ed(parser, token):
+ return EditAdmin(token.split_contents()[1])
+
+register.tag('ed', ed)
View
2 testsobol/mainapp/views.py
@@ -48,7 +48,7 @@ def post(self, request):
class Http(ListView):
- context_object_name = 'request'
+ context_object_name = 'custom_request'
template_name = 'http.html'
paginate_by = 10
View
1 testsobol/settings.py
@@ -100,6 +100,7 @@
TEMPLATE_CONTEXT_PROCESSORS = (
'mainapp.context_processor.settings_context_processor',
'django.contrib.auth.context_processors.auth',
+ 'django.core.context_processors.request',
)
MIDDLEWARE_CLASSES = (
View
10 testsobol/static/style.css
@@ -48,3 +48,13 @@ img{
display:block;
width:370px;
}
+
+h1{
+ float: left;
+}
+
+div.ed{
+ margin-top:30px;
+ margin-left:70px;
+ float:left;
+}
View
4 testsobol/templates/http.html
@@ -1,8 +1,8 @@
{% extends "base.html" %}
{% block content %}
- <h1>10 Requests</h1>
+ <h1 style="float:none;">10 Requests</h1>
<table>
- {% for r in request %}
+ {% for r in custom_request %}
<tr>
<td>{{ r.date }}</td>
<td>{{ r.url }}</td>
View
5 testsobol/templates/index.html
@@ -1,4 +1,5 @@
{% extends "base.html" %}
+{% load my_tags %}
{% block script %}
{% if form %}
@@ -13,6 +14,10 @@
{% block content %}
<h1>42 Coffee Cups Test Assignment</h1>
+ {% if user.is_authenticated %}
+ <div class="ed">{% ed request.user %}</div>
+ {% endif %}
+
{% if form %}
<form method="post" enctype="multipart/form-data" action=".">
{% endif %}
View
2 testsobol/urls.py
@@ -20,5 +20,5 @@
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
- # url(r'^admin/', include(admin.site.urls)),
+ url(r'^admin/', include(admin.site.urls)),
)

0 comments on commit b564e58

Please sign in to comment.