-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for multi-value fields in formsets (#18)
* Added support for multi-value fields in formsets * Update README.md
- Loading branch information
Showing
10 changed files
with
101 additions
and
64 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
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
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,24 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
# ============================================================================== | ||
# | ||
# File Name : thepysec/matina.py | ||
# | ||
# Creation Date : Mon 28 Oct 2019 06:54:11 PM EET (18:54) | ||
# | ||
# Last Modified : Mon 28 Oct 2019 06:54:44 PM EET (18:54) | ||
# | ||
# ============================================================================== | ||
|
||
from thepysec.lia import pop_wsp | ||
|
||
|
||
def pop_i18n_wsp(instance, translated_fields): | ||
""" | ||
In a django model with translated attributes, it strips white space from all | ||
fields of a translated attribute (attribute_en, attribute_fr, attribute_el). | ||
""" | ||
for field in translated_fields: | ||
setattr(instance, field, pop_wsp(getattr(instance, field))) |
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,39 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
|
||
# ============================================================================== | ||
# | ||
# File Name : thepysec/tests/test_matina.py | ||
# | ||
# Creation Date : Mon 28 Oct 2019 06:55:14 PM EET (18:55) | ||
# | ||
# Last Modified : Mon 28 Oct 2019 06:56:05 PM EET (18:56) | ||
# | ||
# ============================================================================== | ||
|
||
from thepysec import matina | ||
|
||
|
||
def test_django_pop_whitespace(): | ||
class A: | ||
att1_en = "f r a" | ||
att1_fr = "h b k" | ||
att1_el = "h f b y k" | ||
att2_en = "r r a" | ||
att2_fr = "h f k" | ||
att2_el = "h f b 1 k" | ||
|
||
obj = A() | ||
trans_fields = ("att1_en", "att1_el", "att1_fr", "att2_en", "att2_el", "att2_fr") | ||
matina.pop_i18n_wsp(obj, trans_fields) | ||
assert all( | ||
( | ||
obj.att1_en == "f r a", | ||
obj.att1_fr == "h b k", | ||
obj.att1_el == "h f b y k", | ||
obj.att2_en == "r r a", | ||
obj.att2_fr == "h f k", | ||
obj.att2_el == "h f b 1 k", | ||
) | ||
) |
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