parent
b79e19cc41
commit
7587ec892f
40 changed files with 449 additions and 73 deletions
@ -1 +1,3 @@ |
||||
from .base import * |
||||
|
||||
INSTALLED_APPS += ['debug_toolbar',] |
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 421 KiB |
|
After Width: | Height: | Size: 191 KiB |
|
After Width: | Height: | Size: 191 KiB |
@ -1,4 +1,7 @@ |
||||
from django.contrib import admin |
||||
from .models import Project |
||||
|
||||
from .models import Project, Portfolio, PortfolioPhoto |
||||
|
||||
admin.site.register(Project) |
||||
admin.site.register(Portfolio) |
||||
admin.site.register(PortfolioPhoto) |
||||
|
||||
@ -1,23 +0,0 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.6 on 2016-05-06 09:36 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.conf import settings |
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
||||
('projects', '0001_initial'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='project', |
||||
name='user', |
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='customers', to=settings.AUTH_USER_MODEL), |
||||
), |
||||
] |
||||
@ -0,0 +1,8 @@ |
||||
from django.core.signals import request_finished |
||||
from django.dispatch import receiver |
||||
from .models import Project |
||||
|
||||
@receiver(request_finished) |
||||
def add_project_test(sender, **kwargs): |
||||
pr = Project.objects.create(name='Test', price=100, user=2, spec=2) |
||||
pr.save() |
||||
@ -1,4 +1,5 @@ |
||||
{% extends "base.html" %} |
||||
{% block content %} |
||||
<h1>{{ object }}</h1> |
||||
<h2>{{ object.user }}</h2> |
||||
{% endblock %}s |
||||
@ -0,0 +1,5 @@ |
||||
from django.contrib import admin |
||||
from mptt.admin import MPTTModelAdmin |
||||
from specialization.models import Specialization |
||||
|
||||
admin.site.register(Specialization, MPTTModelAdmin) |
||||
@ -0,0 +1,5 @@ |
||||
from django.apps import AppConfig |
||||
|
||||
|
||||
class SpecializationConfig(AppConfig): |
||||
name = 'specialization' |
||||
@ -0,0 +1,29 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.6 on 2016-05-12 09:28 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
initial = True |
||||
|
||||
dependencies = [ |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='Category', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('path', models.CharField(max_length=255, unique=True)), |
||||
('depth', models.PositiveIntegerField()), |
||||
('numchild', models.PositiveIntegerField(default=0)), |
||||
('name', models.CharField(max_length=50)), |
||||
], |
||||
options={ |
||||
'abstract': False, |
||||
}, |
||||
), |
||||
] |
||||
@ -0,0 +1,39 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.6 on 2016-05-12 10:13 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
import django.db.models.manager |
||||
import mptt.fields |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('specialization', '0001_initial'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='Specialization', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('name', models.CharField(max_length=100)), |
||||
('lft', models.PositiveIntegerField(db_index=True, editable=False)), |
||||
('rght', models.PositiveIntegerField(db_index=True, editable=False)), |
||||
('tree_id', models.PositiveIntegerField(db_index=True, editable=False)), |
||||
('level', models.PositiveIntegerField(db_index=True, editable=False)), |
||||
('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='specialization.Specialization')), |
||||
], |
||||
options={ |
||||
'abstract': False, |
||||
}, |
||||
managers=[ |
||||
('_default_manager', django.db.models.manager.Manager()), |
||||
], |
||||
), |
||||
migrations.DeleteModel( |
||||
name='Category', |
||||
), |
||||
] |
||||
@ -0,0 +1,19 @@ |
||||
from django.db import models |
||||
from mptt.models import MPTTModel, TreeForeignKey |
||||
from mptt.managers import TreeManager |
||||
|
||||
class Specialization(MPTTModel): |
||||
name = models.CharField(max_length=100) |
||||
parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True) |
||||
|
||||
objects = TreeManager() |
||||
|
||||
def __str__(self): |
||||
return self.name |
||||
|
||||
class MPTTMeta: |
||||
order_insertion_by = ['name'] |
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,30 @@ |
||||
{% extends "base.html" %} |
||||
{% block content %} |
||||
<h1>Специализации</h1> |
||||
{% load mptt_tags %} |
||||
{# {% for spec in object_list %}#} |
||||
{# <h4>{{ spec }}</h4>#} |
||||
{# {% endfor %}#} |
||||
{##} |
||||
{# {% load mptt_tags %}#} |
||||
{#<ul>#} |
||||
{# {% recursetree object_list %}#} |
||||
{# <li>#} |
||||
{# {{ node.name }}#} |
||||
{# {% if not node.is_leaf_node %}#} |
||||
{# <ul class="children">#} |
||||
{# {{ children }}#} |
||||
{# </ul>#} |
||||
{# {% endif %}#} |
||||
{# </li>#} |
||||
{# {% endrecursetree %}#} |
||||
{#</ul>#} |
||||
{{ root }} |
||||
{% for ch in children %} |
||||
<h3>{{ ch }}</h3> |
||||
{% for ch1 in ch.get_children %} |
||||
{{ ch1 }} |
||||
{% endfor %} |
||||
{% endfor %} |
||||
{% endblock %} |
||||
|
||||
@ -0,0 +1,3 @@ |
||||
from django.test import TestCase |
||||
|
||||
# Create your tests here. |
||||
@ -0,0 +1,8 @@ |
||||
from django.conf import urls |
||||
# from django.contrib.auth.views import login, logout |
||||
|
||||
from .views import SpecListView |
||||
|
||||
urlpatterns = [ |
||||
urls.url(r'^$', SpecListView.as_view(), name='spec-list'), |
||||
] |
||||
@ -0,0 +1,16 @@ |
||||
from django.shortcuts import render |
||||
from django.views.generic import ListView |
||||
from .models import Specialization |
||||
|
||||
class SpecListView(ListView): |
||||
model = Specialization |
||||
|
||||
def get_context_data(self, **kwargs): |
||||
context = super(SpecListView, self).get_context_data(**kwargs) |
||||
root = Specialization.objects.get(pk=1) |
||||
context['root'] = root |
||||
context['children'] = root.get_children() |
||||
context['roots'] = Specialization.objects.root_nodes() |
||||
return context |
||||
|
||||
|
||||
@ -0,0 +1,24 @@ |
||||
{% extends 'base.html' %} |
||||
{% block content %} |
||||
<h1>Вход на сайт</h1> |
||||
<form method="post" action=""> |
||||
{% csrf_token %} |
||||
{{ form.errors }} |
||||
<div class="form-group row"> |
||||
<div class="col-md-6"> |
||||
<input type="email" name="{{ form.username.name }}" class="col-xs-6 form-control" id="inputEmail" placeholder="Электронная почта"> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="form-group row"> |
||||
<div class="col-md-6"> |
||||
<input type="password" name="{{ form.password.name }}" class="col-xs-6 form-control" id="inputEmail" placeholder="Пароль"> |
||||
</div> |
||||
</div> |
||||
|
||||
{# {{ form.as_p }}#} |
||||
|
||||
<input type="submit" value="Вход" /> |
||||
<input type="hidden" name="next" value="{{ next }}" /> |
||||
</form> |
||||
{% endblock %} |
||||
@ -0,0 +1,13 @@ |
||||
{% extends 'base.html' %} |
||||
{% block content %} |
||||
<h1>Регистрация</h1> |
||||
<form action="" method="post"> |
||||
{% for field in form %} |
||||
<div class="row"> |
||||
{{ field.label }} |
||||
{{ field }} |
||||
</div> |
||||
{% endfor %} |
||||
<input type="submit" value="Зарегистрировать"> |
||||
</form> |
||||
{% endblock %} |
||||
@ -1,11 +0,0 @@ |
||||
import requests |
||||
|
||||
urls = [ |
||||
"https://habrahabr.ru/all/", |
||||
"https://pythondigest.ru/feed/" |
||||
] |
||||
|
||||
for url in urls: |
||||
req_info = requests.get(url) |
||||
print(req_info.encoding) |
||||
print(req_info.text) |
||||
@ -1,4 +1,5 @@ |
||||
from django.contrib import admin |
||||
from guardian.admin import GuardedModelAdmin |
||||
from .models import CustomUser |
||||
|
||||
admin.site.register(CustomUser) |
||||
admin.site.register(CustomUser, GuardedModelAdmin) |
||||
|
||||
@ -0,0 +1,25 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.6 on 2016-05-11 11:35 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('users', '0001_initial'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='customuser', |
||||
name='firstname', |
||||
field=models.CharField(blank=True, max_length=255), |
||||
), |
||||
migrations.AddField( |
||||
model_name='customuser', |
||||
name='lastname', |
||||
field=models.CharField(blank=True, max_length=255), |
||||
), |
||||
] |
||||
@ -0,0 +1,15 @@ |
||||
{% extends "base.html" %} |
||||
|
||||
|
||||
{% block content %} |
||||
<h2>Исполнители</h2> |
||||
{% for perf in performers %} |
||||
<h1>{{ perf }}</h1> |
||||
{% endfor %} |
||||
|
||||
<h2>Заказчики</h2> |
||||
{% for cust in customers %} |
||||
<h1>{{ cust }}</h1> |
||||
{% endfor %} |
||||
|
||||
{% endblock %} |
||||
@ -1,7 +1,61 @@ |
||||
{% extends "base.html" %} |
||||
|
||||
|
||||
{% block content %} |
||||
<h1>Пользователи</h1> |
||||
{% for user in users %} |
||||
<h3>{{ user }}</h3> |
||||
{% endfor %} |
||||
<div class="titleBlockComparison disTab"> |
||||
<div class="triangle1"></div> |
||||
<p>Дизайн интерьера квартиры 200m2</p> |
||||
<table class="compTable"> |
||||
<tbody><tr> |
||||
<th>№</th> |
||||
<th>Кандидат</th> |
||||
<th>Цена</th> |
||||
<th>Срок</th> |
||||
<th>Описание</th> |
||||
<th>Рейтинги/отзывы</th> |
||||
<th>Безопасные сделки</th> |
||||
<th>Решение</th> |
||||
</tr> |
||||
{% for user in users %} |
||||
<tr> |
||||
<td>1</td> |
||||
<td> |
||||
{{ user.get_full_name }} |
||||
</td> |
||||
<td>35 000 <i class="fa fa-rub"></i></td> |
||||
<td> |
||||
3<br> <span>недели</span> |
||||
</td> |
||||
<td> |
||||
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> |
||||
</td> |
||||
<td> |
||||
<ul> |
||||
<li><span>23 560</span></li> |
||||
<li> |
||||
<span>+385</span> |
||||
0 |
||||
<small> - 0</small> |
||||
</li> |
||||
<li> |
||||
СРО |
||||
</li> |
||||
</ul> |
||||
</td> |
||||
<td> |
||||
<span>5</span><br> |
||||
Готов работать по безопасной сделке |
||||
</td> |
||||
<td> |
||||
<div class="tableButtons disTab"> |
||||
<div class="btnTab btnTab1"></div> |
||||
<div class="btnTab btnTab2"></div> |
||||
<div class="btnTab btnTab3"></div> |
||||
<div class="btnTab btnTab4"></div> |
||||
</div> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</tbody></table> |
||||
</div> |
||||
{% endblock %} |
||||
@ -0,0 +1,8 @@ |
||||
from django import template |
||||
|
||||
register = template.Library() |
||||
|
||||
@register.filter('has_group') |
||||
def has_group(user, group_name): |
||||
groups = user.groups.all().values_list('name', flat=True) |
||||
return True if group_name in groups else False |
||||
@ -1,11 +1,12 @@ |
||||
from django.conf import urls |
||||
from django.contrib.auth.views import login, logout |
||||
|
||||
from .views import UserListView , UserDetailView |
||||
from .views import UserListView, UserDetailView, UserInfoListView |
||||
|
||||
urlpatterns = [ |
||||
urls.url(r'^profile/$', UserDetailView.as_view(), name='user-detail'), |
||||
# urls.url(r'^login/?$', login, {'template_name': 'users/login.html'}), |
||||
# urls.url(r'^logout/?$', logout), |
||||
urls.url(r'^$', UserListView.as_view(), name='users_list'), |
||||
urls.url(r'^info$', UserInfoListView.as_view(), name='users_info_list'), |
||||
] |
||||
Loading…
Reference in new issue