Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
head fork: andreysobol/42test
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
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
13 testsobol/mainapp/tests.py
@@ -38,7 +38,7 @@ class RequestViewTest(TestCase):
def test(self):
page = self.client.get('/http/')
self.assertEqual(page.status_code, 200)
- self.assertTrue(bool(page.context['request']))
+ self.assertTrue(bool(page.context['custom_request']))
class SettingsContextTest(TestCase):
@@ -99,3 +99,14 @@ def test(self):
page = self.client.get('/edit/')
self.assertTrue(page.content.find('>Name:') > page.content.find('Last name:'))
self.assertTrue(page.content.find('Bio:') < page.content.find('Other'))
+
+
+class Tag(TestCase):
+
+ def test(self):
+ fixtures = ['initial_data.json']
+
+ page = self.client.post('/accounts/login/', {'username': 'admin', 'password': 'admin'})
+
+ page = self.client.get('/')
+ self.assertTrue(page.content.find('<a href="/admin/auth/user/1/"') != -1 )
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)),
)

No commit comments for this range

Something went wrong with that request. Please try again.