0001-pages-add-a-default-on-Page.creation_timestamp-field.patch
combo/data/migrations/0042_page_creation_timestamp.py | ||
---|---|---|
16 | 16 |
migrations.AddField( |
17 | 17 |
model_name='page', |
18 | 18 |
name='creation_timestamp', |
19 |
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), |
|
20 |
preserve_default=False, |
|
19 |
field=models.DateTimeField(default=django.utils.timezone.now), |
|
21 | 20 |
), |
22 | 21 |
] |
combo/data/models.py | ||
---|---|---|
47 | 47 |
from django.utils.safestring import mark_safe |
48 | 48 |
from django.utils.six.moves.urllib import parse as urlparse |
49 | 49 |
from django.utils.text import slugify |
50 |
from django.utils.timezone import now |
|
50 | 51 |
from django.utils.translation import ugettext_lazy as _ |
51 | 52 |
from django.forms.widgets import MediaDefiningClass |
52 | 53 |
from django.template import Context, engines, TemplateDoesNotExist, TemplateSyntaxError |
... | ... | |
141 | 142 | |
142 | 143 |
public = models.BooleanField(_('Public'), default=True) |
143 | 144 |
groups = models.ManyToManyField(Group, verbose_name=_('Groups'), blank=True) |
144 |
creation_timestamp = models.DateTimeField(auto_now_add=True)
|
|
145 |
creation_timestamp = models.DateTimeField(default=now)
|
|
145 | 146 |
last_update_timestamp = models.DateTimeField(auto_now=True) |
146 | 147 | |
147 | 148 |
picture = models.ImageField(_('Picture'), upload_to='page-pictures/', null=True) |
tests/test_manager.py | ||
---|---|---|
1442 | 1442 |
assert TextCell.objects.count() == 3 |
1443 | 1443 |
assert JsonCell.objects.count() == 0 |
1444 | 1444 | |
1445 | ||
1446 |
def test_view_old_snapshot(app, admin_user): |
|
1447 |
page = Page.objects.create(title='One', slug='one') |
|
1448 |
PageSnapshot.take(page) |
|
1449 |
snapshot = PageSnapshot.objects.get() |
|
1450 |
# delete creation_timestamp field |
|
1451 |
del snapshot.serialization['fields']['creation_timestamp'] |
|
1452 |
snapshot.save() |
|
1453 |
# and try to visit the snapshot |
|
1454 |
app = login(app) |
|
1455 |
resp = app.get('/manage/pages/%s/' % page.pk) |
|
1456 |
resp = resp.click('History') |
|
1457 |
# should succeed |
|
1458 |
resp = resp.click('view') |
|
1459 | ||
1460 | ||
1445 | 1461 |
def test_django_admin(app, admin_user): |
1446 | 1462 |
resp = app.get('/admin/') |
1447 | 1463 |
resp = resp.follow() # -> /admin/login/ |
1448 |
- |