fix postgresql specific migration and tests (#15213)
This commit is contained in:
parent
06620ee794
commit
2625291a6e
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.db import migrations, models, connection
|
||||
|
||||
def migrate_delivery_count(apps, schema_editor):
|
||||
Broadcast = apps.get_model('corbo', 'Broadcast')
|
||||
|
@ -24,9 +24,13 @@ class Migration(migrations.Migration):
|
|||
('corbo', '0009_auto_20170120_1533'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL('SET CONSTRAINTS ALL IMMEDIATE',
|
||||
reverse_sql=migrations.RunSQL.noop),
|
||||
pg_forward_constraint = [migrations.RunSQL('SET CONSTRAINTS ALL IMMEDIATE',
|
||||
reverse_sql=migrations.RunSQL.noop),]
|
||||
|
||||
pg_backward_constraint = [migrations.RunSQL(migrations.RunSQL.noop,
|
||||
reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),]
|
||||
|
||||
default_operations = [
|
||||
migrations.AddField(
|
||||
model_name='broadcast',
|
||||
name='delivery_count',
|
||||
|
@ -37,6 +41,5 @@ class Migration(migrations.Migration):
|
|||
model_name='broadcast',
|
||||
name='result',
|
||||
),
|
||||
migrations.RunSQL(migrations.RunSQL.noop,
|
||||
reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
|
||||
]
|
||||
operations = pg_forward_constraint + default_operations + pg_backward_constraint if connection.vendor == 'postgresql' else default_operations
|
||||
|
|
|
@ -22,21 +22,18 @@
|
|||
<div class="announce_dashboard">
|
||||
{% if object.publication_time %}
|
||||
<p>
|
||||
<strong>{% trans "Publication" %}</strong>
|
||||
{{ announce.publication_time|date:'DATETIME_FORMAT' }}
|
||||
<strong>{% trans "Publication" %}</strong> {{ announce.publication_time|date:'DATETIME_FORMAT' }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if object.expiration_time %}
|
||||
<p>
|
||||
<strong>{% trans "Expiration" %}</strong>
|
||||
{{ announce.expiration_time|date:'DATETIME_FORMAT' }}
|
||||
<strong>{% trans "Expiration" %}</strong> {{ announce.expiration_time|date:'DATETIME_FORMAT' }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% if broadcasts %}
|
||||
{% for broadcast in broadcasts %}
|
||||
<p>
|
||||
<strong>{% trans "Sent" %}</strong>
|
||||
{{ broadcast.deliver_time|date:'DATETIME_FORMAT' }}
|
||||
<strong>{% trans "Sent" %}</strong> {{ broadcast.deliver_time|date:'DATETIME_FORMAT' }}
|
||||
{% blocktrans count delivers=broadcast.delivery_count %}
|
||||
to {{ delivers }} destination
|
||||
{% plural %}
|
||||
|
|
|
@ -164,15 +164,18 @@ def test_edit_announce(app, admin_user):
|
|||
|
||||
resp = app.get(resp.location)
|
||||
|
||||
assert 'Publication at March 3, 2017, 9 a.m.' in resp.content
|
||||
assert 'Expiration at Dec. 31, 2017, 11 p.m.' in resp.content
|
||||
assert 'Sent at March 30, 2017, 8 p.m. to 1 destination' in resp.content
|
||||
assert '<strong>Publication</strong> March 3, 2017, 9 a.m.' in resp.content
|
||||
assert '<strong>Expiration</strong> Dec. 31, 2017, 11 p.m.' in resp.content
|
||||
print resp.content
|
||||
assert '<strong>Sent</strong> March 30, 2017, 8 p.m.' in resp.content
|
||||
assert 'to 1 destination' in resp.content
|
||||
|
||||
broadcast.delivery_count = 2
|
||||
broadcast.save()
|
||||
|
||||
resp = app.get('http://testserver/manage/announce/1/')
|
||||
assert 'Sent at March 30, 2017, 8 p.m. to 2 destinations' in resp.content
|
||||
assert '<strong>Sent</strong> March 30, 2017, 8 p.m.' in resp.content
|
||||
assert 'to 2 destinations' in resp.content
|
||||
|
||||
|
||||
def test_delete_announce(app, admin_user):
|
||||
|
|
Reference in New Issue