Another date field update

This commit is contained in:
Skia 2016-01-28 10:13:45 +01:00
parent 367fddbdab
commit 2b999d87ba
4 changed files with 64 additions and 40 deletions

View File

@ -18,7 +18,7 @@ class Command(BaseCommand):
call_command('migrate') call_command('migrate')
u = User(username='root', last_name="", first_name="Bibou", u = User(username='root', last_name="", first_name="Bibou",
email="ae.info@utbm.fr", email="ae.info@utbm.fr",
date_of_birth="1942-06-12T00:00:00+01:00", date_of_birth="1942-06-12",
is_superuser=True, is_staff=True) is_superuser=True, is_staff=True)
u.set_password("plop") u.set_password("plop")
u.save() u.save()
@ -28,13 +28,13 @@ class Command(BaseCommand):
print("Dev mode, adding some test data") print("Dev mode, adding some test data")
s = User(username='skia', last_name="Kia", first_name="S'", s = User(username='skia', last_name="Kia", first_name="S'",
email="skia@git.an", email="skia@git.an",
date_of_birth="1942-06-12T00:00:00+01:00", date_of_birth="1942-06-12",
is_superuser=True, is_staff=True) is_superuser=True, is_staff=True)
s.set_password("plop") s.set_password("plop")
s.save() s.save()
u = User(username='guy', last_name="Carlier", first_name="Guy", u = User(username='guy', last_name="Carlier", first_name="Guy",
email="guy@git.an", email="guy@git.an",
date_of_birth="1942-06-12T00:00:00+01:00", date_of_birth="1942-06-12",
is_superuser=False, is_staff=False) is_superuser=False, is_staff=False)
u.set_password("plop") u.set_password("plop")
u.save() u.save()

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0004_auto_20160128_0835'),
]
operations = [
migrations.AlterField(
model_name='user',
name='date_joined',
field=models.DateField(auto_now_add=True, verbose_name='date joined'),
),
]

View File

@ -60,7 +60,7 @@ class User(AbstractBaseUser, PermissionsMixin):
'Unselect this instead of deleting accounts.' 'Unselect this instead of deleting accounts.'
), ),
) )
date_joined = models.DateTimeField(_('date joined'), auto_now_add=True) date_joined = models.DateField(_('date joined'), auto_now_add=True)
owner_group = models.ForeignKey(Group, related_name="owned_user", owner_group = models.ForeignKey(Group, related_name="owned_user",
default=settings.AE_GROUPS['root']['id']) default=settings.AE_GROUPS['root']['id'])
edit_group = models.ManyToManyField(Group, related_name="editable_user", blank=True) edit_group = models.ManyToManyField(Group, related_name="editable_user", blank=True)

View File

@ -1,9 +1,9 @@
from django.test import SimpleTestCase, Client, TestCase from django.test import Client, TestCase
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.core.management import call_command
from core.models import User, Group from core.models import User, Group
#from core.views.forms import RegisteringForm, LoginForm
""" """
to run these tests : to run these tests :
@ -16,8 +16,8 @@ class UserRegistrationTest(TestCase):
def setUp(self): def setUp(self):
try: try:
Group.objects.create(name="root") Group.objects.create(name="root")
except: except Exception as e:
pass print(e)
def test_register_user_form_ok(self): def test_register_user_form_ok(self):
""" """
@ -169,22 +169,23 @@ class PageHandlingTest(TestCase):
Group.objects.create(name="root") Group.objects.create(name="root")
u = User(username='root', last_name="", first_name="Bibou", u = User(username='root', last_name="", first_name="Bibou",
email="ae.info@utbm.fr", email="ae.info@utbm.fr",
date_of_birth="1942-06-12T00:00:00+01:00", date_of_birth="1942-06-12",
is_superuser=True, is_staff=True) is_superuser=True, is_staff=True)
u.set_password("plop") u.set_password("plop")
u.save() u.save()
self.client.login(username='root', password='plop') self.client.login(username='root', password='plop')
except: except Exception as e:
pass print(e)
def test_create_page_ok(self): def test_create_page_ok(self):
""" """
Should create a page correctly Should create a page correctly
""" """
self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {
'name': 'guy', 'parent': '',
'owner_group': '1', 'name': 'guy',
}) 'owner_group': 1,
})
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy'})) response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy'}))
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 200)
self.assertTrue("<strong>guy</strong>" in str(response.content)) self.assertTrue("<strong>guy</strong>" in str(response.content))
@ -193,14 +194,16 @@ class PageHandlingTest(TestCase):
""" """
Should create a page correctly Should create a page correctly
""" """
self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {
'name': 'guy', 'parent': '',
'owner_group': '1', 'name': 'guy',
}) 'owner_group': '1',
response = self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', })
'name': 'bibou', response = self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {
'owner_group': '1', 'parent': '1',
}) 'name': 'bibou',
'owner_group': '1',
})
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'})) response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'}))
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 200)
self.assertTrue("<strong>guy/bibou</strong>" in str(response.content)) self.assertTrue("<strong>guy/bibou</strong>" in str(response.content))
@ -209,17 +212,19 @@ class PageHandlingTest(TestCase):
""" """
Should display a page correctly Should display a page correctly
""" """
self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {
'name': 'guy', 'parent': '',
'title': 'Guy', 'name': 'guy',
'Content': 'Guyéuyuyé', 'title': 'Guy',
}) 'Content': 'Guyéuyuyé',
self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', })
'name': 'bibou', self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {
'title': 'Bibou', 'parent': '1',
'Content': 'name': 'bibou',
'Bibibibiblblblblblbouuuuuuuuu', 'title': 'Bibou',
}) 'Content':
'Bibibibiblblblblblbouuuuuuuuu',
})
response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'})) response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'}))
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 200)
#self.assertTrue('PAGE_FOUND : Bibou' in str(response.content)) #self.assertTrue('PAGE_FOUND : Bibou' in str(response.content))
@ -237,12 +242,12 @@ class PageHandlingTest(TestCase):
""" """
Should format the markdown and escape html correctly Should format the markdown and escape html correctly
""" """
self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {
'name': 'guy', 'parent': '',
'owner_group': '1', 'name': 'guy',
}) 'owner_group': '1',
r = self.client.post(reverse('core:page_edit', kwargs={'page_name': 'guy'}), })
{ r = self.client.post(reverse('core:page_edit', kwargs={'page_name': 'guy'}), {
'title': 'Bibou', 'title': 'Bibou',
'content': 'content':
'''Guy *bibou* '''Guy *bibou*