Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tests pass

  • Loading branch information...
commit 80daa7f71ed7a4736f2cf70eae0ddf1fdedc9c0b 1 parent e05ae6f
andreysobol authored
1  testsobol/mainapp/fixtures/initial_data.json
... ... @@ -0,0 +1 @@
  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"}}]
10 testsobol/mainapp/models.py
... ... @@ -1,3 +1,11 @@
1 1 from django.db import models
2 2
3   -# Create your models here.
  3 +class Bio(models.Model):
  4 + name = models.CharField(max_length=250)
  5 + surname = models.CharField(max_length=250)
  6 + birth = models.DateField()
  7 + email = models.EmailField()
  8 + jabber = models.EmailField()
  9 + skype = models.CharField(max_length=250)
  10 + other = models.TextField()
  11 + bio = models.TextField()
13 testsobol/mainapp/views.py
... ... @@ -1 +1,12 @@
1   -# Create your views here.
  1 +from django.views.generic import TemplateView
  2 +from django.forms.models import model_to_dict
  3 +
  4 +from models import Bio
  5 +
  6 +class Index(TemplateView):
  7 +
  8 + template_name = 'index.html'
  9 +
  10 + def get_context_data(self, **kwargs):
  11 + context = super(Index, self).get_context_data(**kwargs)
  12 + return model_to_dict(Bio.objects.get(pk = 1))
13 testsobol/settings.py
... ... @@ -1,5 +1,7 @@
1 1 # Django settings for testsobol project.
2 2
  3 +import os
  4 +
3 5 DEBUG = True
4 6 TEMPLATE_DEBUG = DEBUG
5 7
@@ -43,6 +45,8 @@
43 45 # calendars according to the current locale
44 46 USE_L10N = True
45 47
  48 +PROJECT_PATH = os.path.dirname(__file__)
  49 +
46 50 # Absolute filesystem path to the directory that will hold user-uploaded files.
47 51 # Example: "/home/media/media.lawrence.com/media/"
48 52 MEDIA_ROOT = ''
@@ -56,7 +60,7 @@
56 60 # Don't put anything in this directory yourself; store your static files
57 61 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
58 62 # Example: "/home/media/media.lawrence.com/static/"
59   -STATIC_ROOT = ''
  63 +#STATIC_ROOT = os.path.join(PROJECT_PATH, 'static')
60 64
61 65 # URL prefix for static files.
62 66 # Example: "http://media.lawrence.com/static/"
@@ -69,6 +73,7 @@
69 73
70 74 # Additional locations of static files
71 75 STATICFILES_DIRS = (
  76 + os.path.join(PROJECT_PATH, 'static'),
72 77 # Put strings here, like "/home/html/static" or "C:/www/django/static".
73 78 # Always use forward slashes, even on Windows.
74 79 # Don't forget to use absolute paths, not relative paths.
@@ -102,11 +107,7 @@
102 107
103 108 ROOT_URLCONF = 'testsobol.urls'
104 109
105   -TEMPLATE_DIRS = (
106   - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
107   - # Always use forward slashes, even on Windows.
108   - # Don't forget to use absolute paths, not relative paths.
109   -)
  110 +TEMPLATE_DIRS = (os.path.join(PROJECT_PATH, 'templates'),)
110 111
111 112 INSTALLED_APPS = (
112 113 'django.contrib.auth',
22 testsobol/static/style.css
... ... @@ -0,0 +1,22 @@
  1 +body{
  2 + width: 800px;
  3 + margin : 0 auto;
  4 +}
  5 +
  6 +li{
  7 + list-style-type: none;
  8 +}
  9 +
  10 +ul{
  11 + padding: 0px;
  12 + margin: 0px;
  13 +}
  14 +
  15 +div.tab{
  16 + float: left;
  17 + width: 400px;
  18 +}
  19 +
  20 +div.multiline{
  21 + margin-top: 15px;
  22 +}
10 testsobol/templates/base.html
... ... @@ -0,0 +1,10 @@
  1 +<!DOCTYPE>
  2 +<html>
  3 + <head>
  4 + <link rel="stylesheet" href="/static/style.css" type="text/css" />
  5 + </head>
  6 + <body>
  7 + {% block content %}
  8 + {% endblock %}
  9 + </body>
  10 +</html>
26 testsobol/templates/index.html
... ... @@ -0,0 +1,26 @@
  1 +{% extends "base.html" %}
  2 +{% block content %}
  3 + <h1>42 Coffee Cups Test Assignment</h1>
  4 + <div class="tab">
  5 + <ul>
  6 + <li>Name: <i>{{ name }}</i></li>
  7 + <li>Last name: <i>{{ surname }}</i></li>
  8 + <li>Date of birth: <i>{{ birth }}</i></li>
  9 + </ul>
  10 + <div class="multiline">
  11 + <div>Bio:</div>
  12 + <div>{{ bio }}</div>
  13 + </div>
  14 + </div>
  15 + <div class="tab">
  16 + <ul>
  17 + <li>Email: <i>{{ email }}</i></li>
  18 + <li>Jabber: <i>{{ jabber }}</i></li>
  19 + <li>Skype: <i>{{ skype }}</i></li>
  20 + </ul>
  21 + <div class="multiline">
  22 + <div>Other contacts:</div>
  23 + <div>{{ other }}</div>
  24 + </div>
  25 + </div>
  26 +{% endblock %}
3  testsobol/urls.py
... ... @@ -1,4 +1,5 @@
1 1 from django.conf.urls.defaults import patterns, include, url
  2 +from testsobol.mainapp.views import Index
2 3
3 4 # Uncomment the next two lines to enable the admin:
4 5 # from django.contrib import admin
@@ -6,7 +7,7 @@
6 7
7 8 urlpatterns = patterns('',
8 9 # Examples:
9   - # url(r'^$', 'testsobol.views.home', name='home'),
  10 + url(r'^$', Index.as_view())#, name='index'),
10 11 # url(r'^testsobol/', include('testsobol.foo.urls')),
11 12
12 13 # Uncomment the admin/doc line below to enable admin documentation:

0 comments on commit 80daa7f

Please sign in to comment.
Something went wrong with that request. Please try again.