Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tests pass

  • Loading branch information...
commit 80daa7f71ed7a4736f2cf70eae0ddf1fdedc9c0b 1 parent e05ae6f
@andreysobol authored
View
1  testsobol/mainapp/fixtures/initial_data.json
@@ -0,0 +1 @@
+[{"pk": 1, "model": "mainapp.bio", "fields": {"bio": "i like rusty spoons", "surname": "Sobol", "name": "Andrey", "other": "pigeon post - white pigeon only", "birth": "1990-09-18", "skype": "andreysobol", "jabber": "pisecs@gmail.com", "email": "asobol@mail.ua"}}]
View
10 testsobol/mainapp/models.py
@@ -1,3 +1,11 @@
from django.db import models
-# Create your models here.
+class Bio(models.Model):
+ name = models.CharField(max_length=250)
+ surname = models.CharField(max_length=250)
+ birth = models.DateField()
+ email = models.EmailField()
+ jabber = models.EmailField()
+ skype = models.CharField(max_length=250)
+ other = models.TextField()
+ bio = models.TextField()
View
13 testsobol/mainapp/views.py
@@ -1 +1,12 @@
-# Create your views here.
+from django.views.generic import TemplateView
+from django.forms.models import model_to_dict
+
+from models import Bio
+
+class Index(TemplateView):
+
+ template_name = 'index.html'
+
+ def get_context_data(self, **kwargs):
+ context = super(Index, self).get_context_data(**kwargs)
+ return model_to_dict(Bio.objects.get(pk = 1))
View
13 testsobol/settings.py
@@ -1,5 +1,7 @@
# Django settings for testsobol project.
+import os
+
DEBUG = True
TEMPLATE_DEBUG = DEBUG
@@ -43,6 +45,8 @@
# calendars according to the current locale
USE_L10N = True
+PROJECT_PATH = os.path.dirname(__file__)
+
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
@@ -56,7 +60,7 @@
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
-STATIC_ROOT = ''
+#STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
@@ -69,6 +73,7 @@
# Additional locations of static files
STATICFILES_DIRS = (
+ os.path.join(PROJECT_PATH, 'static'),
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
@@ -102,11 +107,7 @@
ROOT_URLCONF = 'testsobol.urls'
-TEMPLATE_DIRS = (
- # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
- # Always use forward slashes, even on Windows.
- # Don't forget to use absolute paths, not relative paths.
-)
+TEMPLATE_DIRS = (os.path.join(PROJECT_PATH, 'templates'),)
INSTALLED_APPS = (
'django.contrib.auth',
View
22 testsobol/static/style.css
@@ -0,0 +1,22 @@
+body{
+ width: 800px;
+ margin : 0 auto;
+}
+
+li{
+ list-style-type: none;
+}
+
+ul{
+ padding: 0px;
+ margin: 0px;
+}
+
+div.tab{
+ float: left;
+ width: 400px;
+}
+
+div.multiline{
+ margin-top: 15px;
+}
View
10 testsobol/templates/base.html
@@ -0,0 +1,10 @@
+<!DOCTYPE>
+<html>
+ <head>
+ <link rel="stylesheet" href="/static/style.css" type="text/css" />
+ </head>
+ <body>
+ {% block content %}
+ {% endblock %}
+ </body>
+</html>
View
26 testsobol/templates/index.html
@@ -0,0 +1,26 @@
+{% extends "base.html" %}
+{% block content %}
+ <h1>42 Coffee Cups Test Assignment</h1>
+ <div class="tab">
+ <ul>
+ <li>Name: <i>{{ name }}</i></li>
+ <li>Last name: <i>{{ surname }}</i></li>
+ <li>Date of birth: <i>{{ birth }}</i></li>
+ </ul>
+ <div class="multiline">
+ <div>Bio:</div>
+ <div>{{ bio }}</div>
+ </div>
+ </div>
+ <div class="tab">
+ <ul>
+ <li>Email: <i>{{ email }}</i></li>
+ <li>Jabber: <i>{{ jabber }}</i></li>
+ <li>Skype: <i>{{ skype }}</i></li>
+ </ul>
+ <div class="multiline">
+ <div>Other contacts:</div>
+ <div>{{ other }}</div>
+ </div>
+ </div>
+{% endblock %}
View
3  testsobol/urls.py
@@ -1,4 +1,5 @@
from django.conf.urls.defaults import patterns, include, url
+from testsobol.mainapp.views import Index
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
@@ -6,7 +7,7 @@
urlpatterns = patterns('',
# Examples:
- # url(r'^$', 'testsobol.views.home', name='home'),
+ url(r'^$', Index.as_view())#, name='index'),
# url(r'^testsobol/', include('testsobol.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
Please sign in to comment.
Something went wrong with that request. Please try again.