forked from die-trying/django-celery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature_promoting_hosted_lessons
- Loading branch information
Showing
22 changed files
with
92 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ machine: | |
version: 3.4.3 | ||
|
||
node: | ||
version: 4.2.6 | ||
version: 6.1.0 | ||
|
||
services: | ||
- redis | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
def drop_customer_profiles_without_user(apps, schema_editor): | ||
Customer = apps.get_model('crm.Customer') | ||
Customer.objects.filter(user__isnull=True).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('crm', '0022_auto_20161220_1234'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL('SET CONSTRAINTS ALL IMMEDIATE'), | ||
migrations.RunPython(drop_customer_profiles_without_user), | ||
migrations.AlterField( | ||
model_name='customer', | ||
name='user', | ||
field=models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='crm'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
from django.core.exceptions import ValidationError | ||
from mixer.backend.django import mixer | ||
|
||
from crm.models import Customer | ||
from elk.utils.testing import TestCase, create_customer | ||
from lessons import models as lessons | ||
from market.models import Class | ||
|
||
|
||
class CustomerTestCase(TestCase): | ||
fixtures = ('crm',) | ||
# fixtures = ('crm',) | ||
|
||
def test_username(self): | ||
def test_user_model(self): | ||
""" | ||
Customer objects with assigned django user should take user data from | ||
the django table. | ||
""" | ||
customer_with_user = Customer.objects.get(pk=1) | ||
self.assertEqual(customer_with_user.full_name, 'Fedor Borshev') | ||
self.assertEqual(customer_with_user.first_name, 'Fedor') | ||
self.assertEqual(customer_with_user.last_name, 'Borshev') | ||
self.assertEqual(customer_with_user.email, '[email protected]') | ||
customer = create_customer() | ||
|
||
customer.user.first_name = 'Fedor' | ||
customer.user.last_name = 'Borshev' | ||
customer.user.email = '[email protected]' | ||
customer.user.save() | ||
|
||
self.assertEqual(customer.full_name, 'Fedor Borshev') | ||
self.assertEqual(customer.first_name, 'Fedor') | ||
self.assertEqual(customer.last_name, 'Borshev') | ||
self.assertEqual(customer.email, '[email protected]') | ||
|
||
def test_can_cancel_classes(self): | ||
customer = create_customer() | ||
|
@@ -66,3 +72,7 @@ def test_get_absolute_url(self): | |
url = c.get_absolute_url() | ||
self.assertIn(str(c.pk), url) | ||
self.assertIn('/admin/', url) | ||
|
||
def test_customer_profile_automaticaly_emerges_when_creating_stock_django_user(self): | ||
u = mixer.blend('auth.User') | ||
self.assertIsNotNone(u.crm) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,33 +42,21 @@ def __add_working_hours_24x7(teacher): | |
) | ||
|
||
|
||
def create_user(**kwargs): | ||
def create_customer(password=None, **kwargs): | ||
""" | ||
Generate a simple user object. | ||
You can pass `mixer<https://github.com/klen/mixer>` keyword arguments for :model:`crm.Customer` | ||
or 'password' argument if you want to log in with this user | ||
Generate a simple customer object. | ||
""" | ||
user = mixer.blend('auth.user') | ||
|
||
if kwargs.get('password'): | ||
user.set_password(kwargs.pop('password')) | ||
if password is not None: | ||
user.set_password(password) | ||
user.save() | ||
|
||
user.crm = create_customer(user=user, **kwargs) | ||
|
||
return user | ||
|
||
if(kwargs): | ||
for attr, value in kwargs.items(): | ||
setattr(user.crm, attr, value) | ||
|
||
def create_customer(user=None, **kwargs): | ||
""" | ||
Generate a simple customer object. | ||
""" | ||
if user is None: | ||
user = create_user(**kwargs) | ||
else: | ||
kwargs['timezone'] = kwargs.get('timezone', 'Europe/Moscow') # the timezone value here deffers from default one in settings.py for early timezone error detection | ||
mixer.blend('crm.customer', user=user, **kwargs) | ||
user.crm.save() | ||
|
||
return user.crm | ||
|
||
|
@@ -167,7 +155,6 @@ class SuperUserTestCaseMixin(): | |
@classmethod | ||
def _generate_superuser(cls): | ||
cls.superuser = User.objects.create_superuser('root', '[email protected]', 'ohGh7jai4Cee') | ||
create_customer(user=cls.superuser) | ||
cls.superuser_login = 'root' | ||
cls.superuser_password = 'ohGh7jai4Cee' # store, if children will need it | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters