-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1126 from jefmoura/441-update-public-customform
Update the public options of customform
- Loading branch information
Showing
7 changed files
with
151 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.3 on 2018-08-06 15:08 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('formlibrary', '0011_set_customform_public'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='customform', | ||
name='public', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.3 on 2018-08-07 11:36 | ||
from __future__ import unicode_literals | ||
|
||
import django.contrib.postgres.fields.jsonb | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('formlibrary', '0012_remove_customform_public'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='customform', | ||
name='public', | ||
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, help_text='Public information with the structure:{org: (bool), url: (bool)}', null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='customform', | ||
name='fields', | ||
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.3 on 2018-08-07 14:02 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
from ..models import CustomForm | ||
|
||
|
||
def set_form_public(apps, schema_editor): | ||
CustomForm.objects.filter(is_public=True).update( | ||
public={'org': True, 'url': False}) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('formlibrary', '0013_auto_20180807_0436'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(set_form_public), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
from django.core.exceptions import ValidationError | ||
from django.test import TestCase, tag | ||
|
||
import factories | ||
from formlibrary.models import CustomForm | ||
|
||
|
||
@tag('pkg') | ||
class CustomFormTest(TestCase): | ||
def setUp(self): | ||
self.organization = factories.Organization() | ||
self.user = factories.User() | ||
|
||
def test_save_without_public_info(self): | ||
custom_form = CustomForm( | ||
organization=self.organization, | ||
name="Humanitec's Survey", | ||
fields="{}", | ||
public={} | ||
) | ||
|
||
self.assertRaises(ValidationError, custom_form.save) | ||
|
||
def test_save_without_public_org_info(self): | ||
custom_form = CustomForm( | ||
organization=self.organization, | ||
name="Humanitec's Survey", | ||
fields="{}", | ||
public={'url': True} | ||
) | ||
|
||
self.assertRaises(ValidationError, custom_form.save) | ||
|
||
def test_save_without_public_url_info(self): | ||
custom_form = CustomForm( | ||
organization=self.organization, | ||
name="Humanitec's Survey", | ||
fields="{}", | ||
public={'org': True} | ||
) | ||
|
||
self.assertRaises(ValidationError, custom_form.save) | ||
|
||
def test_save_with_public_info(self): | ||
custom_form = CustomForm.objects.create( | ||
organization=self.organization, | ||
name="Humanitec's Survey", | ||
fields="{}", | ||
public={'org': True, 'url': True} | ||
) | ||
|
||
self.assertEqual(custom_form.name, "Humanitec's Survey") | ||
self.assertEqual(custom_form.public, {'org': True, 'url': True}) |