From 0e222dd8c467969d64405447cb2def4163695465 Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Thu, 19 May 2016 13:03:56 +0300 Subject: [PATCH 1/2] Update --- README.md | 13 +++++++++---- requirements/humans.txt | 1 - 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 500ae35..3eb2627 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ ### Setup -Install a virtualenv: +Go to a folder and install a virtualenv: ``` -virtualenv env --python python3.5 && \ -source env/bin/activate && \ -pip install --requirement humans.txt +cd path/to/venv/folder && \ +virtualenv . --python python3.5 && \ +source bin/activate && \ +pip install --requirement path/to/requirements.txt ``` ``` @@ -16,3 +17,7 @@ python manage.py migrate ``` python manage.py runserver ``` + +``` +python manage.py shell_plus --use-pythonrc +``` diff --git a/requirements/humans.txt b/requirements/humans.txt index f7d1357..183e9a8 100644 --- a/requirements/humans.txt +++ b/requirements/humans.txt @@ -1,4 +1,3 @@ -#django-guardian Django django-debug-toolbar django-environ From ce2293657bbe2abedad9f2b87f5bdf773a327c9d Mon Sep 17 00:00:00 2001 From: ArturBaybulatov Date: Thu, 19 May 2016 13:34:32 +0300 Subject: [PATCH 2/2] Migration fix and seed_data.py modified --- archilance/management/commands/seed_data.py | 14 +++++--- projects/migrations/0001_initial.py | 25 ++++++++----- projects/migrations/0002_answer.py | 31 ---------------- .../migrations/0002_auto_20160519_1022.py | 35 +++++++++++++++++++ .../migrations/0003_auto_20160518_1132.py | 23 ------------ specializations/migrations/0001_initial.py | 2 +- users/migrations/0001_initial.py | 13 +++++-- users/migrations/0002_auto_20160519_0807.py | 27 -------------- users/models.py | 15 +++----- 9 files changed, 77 insertions(+), 108 deletions(-) delete mode 100644 projects/migrations/0002_answer.py create mode 100644 projects/migrations/0002_auto_20160519_1022.py delete mode 100644 projects/migrations/0003_auto_20160518_1132.py delete mode 100644 users/migrations/0002_auto_20160519_0807.py diff --git a/archilance/management/commands/seed_data.py b/archilance/management/commands/seed_data.py index 036bc48..1103ce6 100644 --- a/archilance/management/commands/seed_data.py +++ b/archilance/management/commands/seed_data.py @@ -1,10 +1,8 @@ # from cms_pages.models import Menu, CmsPage # from django.contrib import sites # from django.core.files import File -from django.core.management import BaseCommand # from django.db import connection # from django.db.models import Q -from django.utils import timezone # from pprint import pprint, pformat # from wagtail.wagtailcore.models import Page # import copy @@ -13,10 +11,13 @@ from django.utils import timezone # import itertools # import json # import os -import pydash as _; _.map = _.map_; _.filter = _.filter_ -import random # import requests # import util +from django.core.management import BaseCommand +from django.utils import timezone +import pydash as _; _.map = _.map_; _.filter = _.filter_ +import random +from django.contrib.auth.models import Group from users.models import User @@ -71,7 +72,10 @@ class Command(BaseCommand): is_active=_.sample((True, False)), ) - users = _.times(create_user, 100) + Group.objects.create(name='Исполнители') + Group.objects.create(name='Заказчики') + + users = _.times(create_user, 50) for user in users: user.set_password('123') diff --git a/projects/migrations/0001_initial.py b/projects/migrations/0001_initial.py index 7191b94..3e88e10 100644 --- a/projects/migrations/0001_initial.py +++ b/projects/migrations/0001_initial.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-18 16:08 +# Generated by Django 1.9.6 on 2016-05-19 10:22 from __future__ import unicode_literals -from django.conf import settings from django.db import migrations, models import django.db.models.deletion @@ -12,18 +11,30 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('specializations', '__first__'), ] operations = [ + migrations.CreateModel( + name='Answer', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('cost', models.DecimalField(decimal_places=2, max_digits=10)), + ('cost_type', models.CharField(choices=[('RUR', 'rur'), ('USD', 'usd'), ('EUR', 'eur')], default='RUR', max_length=5)), + ('text', models.TextField()), + ('term', models.DecimalField(decimal_places=2, max_digits=10)), + ('term_type', models.CharField(choices=[('HOUR', 'hour'), ('DAY', 'day'), ('MONTH', 'month')], default='hour', max_length=10)), + ], + options={ + 'verbose_name': 'Ответ к проекту', + 'verbose_name_plural': 'Ответы к проектам', + }, + ), migrations.CreateModel( name='Portfolio', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=255)), ('description', models.TextField()), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], ), migrations.CreateModel( @@ -41,12 +52,10 @@ class Migration(migrations.Migration): ('name', models.CharField(max_length=255)), ('price', models.DecimalField(decimal_places=2, max_digits=10)), ('text', models.TextField(blank=True)), - ('specialization', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='projects', to='specializations.Specialization')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='projects', to=settings.AUTH_USER_MODEL)), ], options={ - 'verbose_name_plural': 'Проекты', 'verbose_name': 'Проект', + 'verbose_name_plural': 'Проекты', }, ), ] diff --git a/projects/migrations/0002_answer.py b/projects/migrations/0002_answer.py deleted file mode 100644 index 7315213..0000000 --- a/projects/migrations/0002_answer.py +++ /dev/null @@ -1,31 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-19 08:44 -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.CreateModel( - name='Answer', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('cost', models.DecimalField(decimal_places=2, max_digits=10)), - ('cost_type', models.CharField(choices=[('RUR', 'rur'), ('USD', 'usd'), ('EUR', 'eur')], default='RUR', max_length=5)), - ('text', models.TextField()), - ('term', models.DecimalField(decimal_places=2, max_digits=10)), - ('term_type', models.CharField(choices=[('HOUR', 'hour'), ('DAY', 'day'), ('MONTH', 'month')], default='hour', max_length=10)), - ('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='projects.Project')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to=settings.AUTH_USER_MODEL)), - ], - ), - ] diff --git a/projects/migrations/0002_auto_20160519_1022.py b/projects/migrations/0002_auto_20160519_1022.py new file mode 100644 index 0000000..a2bcea9 --- /dev/null +++ b/projects/migrations/0002_auto_20160519_1022.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-05-19 10:22 +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): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('projects', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='portfolio', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + migrations.AddField( + model_name='answer', + name='project', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='projects.Project'), + ), + migrations.AddField( + model_name='answer', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/projects/migrations/0003_auto_20160518_1132.py b/projects/migrations/0003_auto_20160518_1132.py deleted file mode 100644 index b6371b3..0000000 --- a/projects/migrations/0003_auto_20160518_1132.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-18 11:32 -from __future__ import unicode_literals - -from django.db import migrations - - -class Migration(migrations.Migration): - - dependencies = [ - ('projects', '0002_auto_20160517_0903'), - ] - - operations = [ - migrations.RemoveField( - model_name='project', - name='specialization', - ), - migrations.RemoveField( - model_name='project', - name='user', - ), - ] diff --git a/specializations/migrations/0001_initial.py b/specializations/migrations/0001_initial.py index 3fd29b0..24f3999 100644 --- a/specializations/migrations/0001_initial.py +++ b/specializations/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-18 16:08 +# Generated by Django 1.9.6 on 2016-05-19 10:22 from __future__ import unicode_literals from django.db import migrations, models diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py index 13202cd..3461989 100644 --- a/users/migrations/0001_initial.py +++ b/users/migrations/0001_initial.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-18 16:08 +# Generated by Django 1.9.6 on 2016-05-19 10:22 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): @@ -30,7 +31,8 @@ class Migration(migrations.Migration): ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), ], options={ - 'abstract': False, + 'verbose_name': 'Пользователь', + 'verbose_name_plural': 'Пользователи', }, ), migrations.CreateModel( @@ -38,7 +40,12 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=255)), - ('users', models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL)), + ('owner', models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='team', to=settings.AUTH_USER_MODEL)), + ('users', models.ManyToManyField(blank=True, related_name='teams', to=settings.AUTH_USER_MODEL)), ], + options={ + 'verbose_name': 'Команда', + 'verbose_name_plural': 'Команды', + }, ), ] diff --git a/users/migrations/0002_auto_20160519_0807.py b/users/migrations/0002_auto_20160519_0807.py deleted file mode 100644 index 1a60afb..0000000 --- a/users/migrations/0002_auto_20160519_0807.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.6 on 2016-05-19 08:07 -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 = [ - ('users', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='team', - name='owner', - field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='team', to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='team', - name='users', - field=models.ManyToManyField(blank=True, related_name='teams', to=settings.AUTH_USER_MODEL), - ), - ] diff --git a/users/models.py b/users/models.py index 5cd072e..b3f8e0a 100644 --- a/users/models.py +++ b/users/models.py @@ -35,11 +35,11 @@ class User(AbstractBaseUser, PermissionsMixin): last_name = models.CharField(max_length=255, blank=True) email = models.EmailField(max_length=255, unique=True, db_index=True) is_active = models.BooleanField(default=True) - + @property def is_staff(self): return self.is_superuser - + def __str__(self): return self.email @@ -54,7 +54,7 @@ class User(AbstractBaseUser, PermissionsMixin): objects = UserManager() perform_objects = PerformUserManager() customers_objects = CustomerUserManager() - + class Meta: verbose_name = 'Пользователь' verbose_name_plural = 'Пользователи' @@ -64,15 +64,10 @@ class Team(models.Model): name = models.CharField(max_length=255) users = models.ManyToManyField(User, related_name ='teams', blank=True) owner = models.OneToOneField(User, related_name='team', null=True) - + def __str__(self): return self.name -<<<<<<< HEAD - + class Meta: verbose_name = 'Команда' verbose_name_plural = 'Команды' - - -======= ->>>>>>> f73c8cbb03160dbcba5094bb2be837d43d1e5f31