Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ticket: zbr#292 timezone #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
*.sqlite*
_build
build
.idea/*
92 changes: 92 additions & 0 deletions eav/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.manager
import datetime
import eav.fields
import django.contrib.sites.managers


class Migration(migrations.Migration):

dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('sites', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Attribute',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(help_text='User-friendly attribute name', max_length=100, verbose_name='name')),
('slug', eav.fields.EavSlugField(help_text='Short unique attribute label', verbose_name='slug')),
('description', models.CharField(help_text='Short description', max_length=256, null=True, verbose_name='description', blank=True)),
('type', models.CharField(max_length=20, null=True, verbose_name='type', blank=True)),
('datatype', eav.fields.EavDatatypeField(max_length=6, verbose_name='data type', choices=[(b'text', 'Text'), (b'float', 'Float'), (b'int', 'Integer'), (b'date', 'Date'), (b'bool', 'True / False'), (b'object', 'Django Object'), (b'enum', 'Multiple Choice')])),
('created', models.DateTimeField(default=datetime.datetime.now, verbose_name='created', editable=False)),
('modified', models.DateTimeField(auto_now=True, verbose_name='modified')),
('required', models.BooleanField(default=False, verbose_name='required')),
],
options={
'ordering': ['name'],
},
managers=[
('objects', django.db.models.manager.Manager()),
('on_site', django.contrib.sites.managers.CurrentSiteManager()),
],
),
migrations.CreateModel(
name='EnumGroup',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(unique=True, max_length=100, verbose_name='name')),
],
),
migrations.CreateModel(
name='EnumValue',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('value', models.CharField(unique=True, max_length=50, verbose_name='value', db_index=True)),
],
),
migrations.CreateModel(
name='Value',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('entity_id', models.IntegerField()),
('value_text', models.TextField(null=True, blank=True)),
('value_float', models.FloatField(null=True, blank=True)),
('value_int', models.IntegerField(null=True, blank=True)),
('value_date', models.DateTimeField(null=True, blank=True)),
('value_bool', models.NullBooleanField()),
('generic_value_id', models.IntegerField(null=True, blank=True)),
('created', models.DateTimeField(default=datetime.datetime.now, verbose_name='created')),
('modified', models.DateTimeField(auto_now=True, verbose_name='modified')),
('attribute', models.ForeignKey(verbose_name='attribute', to='eav.Attribute')),
('entity_ct', models.ForeignKey(related_name='value_entities', to='contenttypes.ContentType')),
('generic_value_ct', models.ForeignKey(related_name='value_values', blank=True, to='contenttypes.ContentType', null=True)),
('value_enum', models.ForeignKey(related_name='eav_values', blank=True, to='eav.EnumValue', null=True)),
],
),
migrations.AddField(
model_name='enumgroup',
name='enums',
field=models.ManyToManyField(to='eav.EnumValue', verbose_name='enum group'),
),
migrations.AddField(
model_name='attribute',
name='enum_group',
field=models.ForeignKey(verbose_name='choice group', blank=True, to='eav.EnumGroup', null=True),
),
migrations.AddField(
model_name='attribute',
name='site',
field=models.ForeignKey(default=1, verbose_name='site', to='sites.Site'),
),
migrations.AlterUniqueTogether(
name='attribute',
unique_together=set([('site', 'slug')]),
),
]
25 changes: 25 additions & 0 deletions eav/migrations/0002_auto_20160405_0906.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('eav', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='attribute',
name='created',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='created', editable=False),
),
migrations.AlterField(
model_name='value',
name='created',
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='created'),
),
]
Empty file added eav/migrations/__init__.py
Empty file.
9 changes: 4 additions & 5 deletions eav/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
Classes
-------
'''

from datetime import datetime
from django.utils import timezone

from django.db import models
from django.core.exceptions import ValidationError
Expand Down Expand Up @@ -177,7 +176,7 @@ class Meta:
help_text=_(u"User-friendly attribute name"))

site = models.ForeignKey(Site, verbose_name=_(u"site"),
default=Site.objects.get_current)
default=settings.SITE_ID)

slug = EavSlugField(_(u"slug"), max_length=50, db_index=True,
help_text=_(u"Short unique attribute label"))
Expand All @@ -198,7 +197,7 @@ def help_text(self):
datatype = EavDatatypeField(_(u"data type"), max_length=6,
choices=DATATYPE_CHOICES)

created = models.DateTimeField(_(u"created"), default=datetime.now,
created = models.DateTimeField(_(u"created"), default=timezone.now,
editable=False)

modified = models.DateTimeField(_(u"modified"), auto_now=True)
Expand Down Expand Up @@ -354,7 +353,7 @@ class Value(models.Model):
value_object = generic.GenericForeignKey(ct_field='generic_value_ct',
fk_field='generic_value_id')

created = models.DateTimeField(_(u"created"), default=datetime.now)
created = models.DateTimeField(_(u"created"), default=timezone.now)
modified = models.DateTimeField(_(u"modified"), auto_now=True)

attribute = models.ForeignKey(Attribute, db_index=True,
Expand Down