-
Notifications
You must be signed in to change notification settings - Fork 31
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
Replace auto_now and auto_now_add with defaults which can be overridden #93
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,5 @@ celerybeat-schedule | |
|
||
*.DS_Store | ||
.tox/ | ||
test-runner/env/ | ||
test-runner/smartmin | ||
csv_imports/ | ||
!smartmin/csv_imports/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need this so we exclude /csv_imports but include /smartmin/csv_imports/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.10.4 on 2017-02-23 09:17 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('csv_imports', '0003_importtask_task_status'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='importtask', | ||
name='created_on', | ||
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, help_text='When this item was originally created'), | ||
), | ||
migrations.AlterField( | ||
model_name='importtask', | ||
name='modified_on', | ||
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, help_text='When this item was last modified'), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
import pytz | ||
import six | ||
|
||
from six import text_type | ||
from django.conf import settings | ||
from django.db import models | ||
from django.utils import timezone | ||
|
@@ -37,15 +36,23 @@ class SmartModel(models.Model): | |
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, | ||
related_name="%(app_label)s_%(class)s_creations", | ||
help_text="The user which originally created this item") | ||
created_on = models.DateTimeField(auto_now_add=True, | ||
created_on = models.DateTimeField(default=timezone.now, editable=False, blank=True, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
help_text="When this item was originally created") | ||
|
||
modified_by = models.ForeignKey(settings.AUTH_USER_MODEL, | ||
related_name="%(app_label)s_%(class)s_modifications", | ||
help_text="The user which last modified this item") | ||
modified_on = models.DateTimeField(auto_now=True, | ||
modified_on = models.DateTimeField(default=timezone.now, editable=False, blank=True, | ||
help_text="When this item was last modified") | ||
|
||
def save(self, *args, **kwargs): | ||
update_fields = kwargs.get('update_fields', None) | ||
|
||
if (update_fields is None or 'modified_on' in update_fields) and not kwargs.pop('preserve_modified_on', False): | ||
self.modified_on = timezone.now() | ||
|
||
return super(SmartModel, self).save(*args, **kwargs) | ||
|
||
class Meta: | ||
abstract = True | ||
|
||
|
@@ -240,12 +247,12 @@ def import_xls(cls, filename, user, import_params, log=None, import_results=None | |
num_errors += 1 | ||
|
||
except SmartImportRowError as e: | ||
error_messages.append(dict(line=line_number+1, error=text_type(e))) | ||
error_messages.append(dict(line=line_number+1, error=six.text_type(e))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just making this consistent with how the method is called elsewhere in this file |
||
|
||
except Exception as e: | ||
if log: | ||
traceback.print_exc(100, log) | ||
raise Exception("Line %d: %s\n\n%s" % (line_number, text_type(e), field_values)) | ||
raise Exception("Line %d: %s\n\n%s" % (line_number, six.text_type(e), field_values)) | ||
line_number += 1 | ||
# only care about the first sheet | ||
break | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.10.4 on 2017-02-23 09:17 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('blog', '0002_post_uuid'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='category', | ||
name='created_on', | ||
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, help_text='When this item was originally created'), | ||
), | ||
migrations.AlterField( | ||
model_name='category', | ||
name='modified_on', | ||
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, help_text='When this item was last modified'), | ||
), | ||
migrations.AlterField( | ||
model_name='post', | ||
name='created_on', | ||
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, help_text='When this item was originally created'), | ||
), | ||
migrations.AlterField( | ||
model_name='post', | ||
name='modified_on', | ||
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, editable=False, help_text='When this item was last modified'), | ||
), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't exist