Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
campaign
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
campaign
Commits
4a7f5edc
Commit
4a7f5edc
authored
Jan 19, 2017
by
okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moving to a djangobased translatiosn for texts
parent
da2b0027
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
10 additions
and
27 deletions
+10
-27
picampaign/campaign/admin.py
picampaign/campaign/admin.py
+1
-1
picampaign/campaign/models.py
picampaign/campaign/models.py
+3
-11
picampaign/campaign/serializers.py
picampaign/campaign/serializers.py
+1
-1
picampaign/campaign/test_admin.py
picampaign/campaign/test_admin.py
+0
-1
picampaign/campaign/test_models.py
picampaign/campaign/test_models.py
+1
-2
picampaign/campaign/test_serializers.py
picampaign/campaign/test_serializers.py
+1
-2
picampaign/campaign/test_views.py
picampaign/campaign/test_views.py
+3
-4
picampaign/campaign/views.py
picampaign/campaign/views.py
+0
-5
No files found.
picampaign/campaign/admin.py
View file @
4a7f5edc
...
...
@@ -11,7 +11,7 @@ class InlineImporter(admin.TabularInline):
model
=
Importer
class
CampaignAdmin
(
admin
.
ModelAdmin
):
inlines
=
[
InlineContact
,
Importer
]
inlines
=
[
InlineContact
,
I
nlineI
mporter
]
def
get_queryset
(
self
,
request
):
qs
=
super
(
CampaignAdmin
,
self
).
get_queryset
(
request
)
...
...
picampaign/campaign/models.py
View file @
4a7f5edc
...
...
@@ -6,8 +6,6 @@ from picampaign.organization.models import Organization
from
picampaign.contact.models
import
Contact
LANGUAGES
=
map
(
lambda
k
:
(
k
[
0
],
_
(
k
[
1
])),
settings
.
LANGUAGES
)
class
Campaign
(
models
.
Model
):
"""Campaign model, describe what have to be achieved"""
id
=
models
.
AutoField
(
primary_key
=
True
)
...
...
@@ -16,27 +14,21 @@ class Campaign(models.Model):
organization
=
models
.
ForeignKey
(
Organization
,
related_name
=
'campaigns'
)
start_date
=
models
.
DateField
()
end_date
=
models
.
DateField
()
default_lang
=
models
.
CharField
(
max_length
=
5
,
choices
=
LANGUAGES
,
verbose_name
=
_
(
'language'
))
phone_filter
=
models
.
CharField
(
max_length
=
20
,
null
=
True
,
blank
=
True
)
def
__str__
(
self
):
return
self
.
title
class
Argumentary
(
models
.
Model
):
"""Argumentary
in a given language
for a campaign"""
"""Argumentary for a campaign"""
id
=
models
.
AutoField
(
primary_key
=
True
)
campaign
=
models
.
ForeignKey
(
Campaign
)
lang
=
models
.
CharField
(
max_length
=
5
,
choices
=
LANGUAGES
,
verbose_name
=
_
(
'language'
))
title
=
models
.
CharField
(
max_length
=
255
,
verbose_name
=
_
(
'title'
),
null
=
True
,
blank
=
True
)
text
=
models
.
TextField
(
null
=
True
)
def
__str__
(
self
):
args
=
{
'
lang'
:
self
.
lang
,
'
title'
:
self
.
campaign
.
title
}
return
_
(
'Argumentary
in %(lang)s
for %(title)s'
)
%
args
args
=
{
'title'
:
self
.
campaign
.
title
}
return
_
(
'Argumentary for %(title)s'
)
%
args
class
CampaignContact
(
models
.
Model
):
"""List contact related to a campaign with a given weight"""
...
...
picampaign/campaign/serializers.py
View file @
4a7f5edc
...
...
@@ -9,7 +9,7 @@ class ArgumentarySerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Argumentary
fields
=
(
'
lang'
,
'
text'
,
'title'
)
fields
=
(
'text'
,
'title'
)
class
PhoneSerializer
(
serializers
.
ModelSerializer
):
...
...
picampaign/campaign/test_admin.py
View file @
4a7f5edc
...
...
@@ -22,7 +22,6 @@ class ArgumentaryAdminTest(TestCase):
organization
=
self
.
organization
)
self
.
argumentary
=
Argumentary
.
objects
.
create
(
lang
=
'en'
,
text
=
'A pertinent argument'
,
campaign
=
self
.
campaign
)
...
...
picampaign/campaign/test_models.py
View file @
4a7f5edc
...
...
@@ -15,10 +15,9 @@ class ArgumentaryMethodTests(TestCase):
)
argumentary
=
Argumentary
(
campaign
=
campaign
,
lang
=
'fr'
,
text
=
'Argument number 1'
)
self
.
assertEqual
(
str
(
argumentary
),
'Argumentary
in fr
for Campaign Title'
)
self
.
assertEqual
(
str
(
argumentary
),
'Argumentary for Campaign Title'
)
class
CampaignMethodTests
(
TestCase
):
def
test_str
(
self
):
...
...
picampaign/campaign/test_serializers.py
View file @
4a7f5edc
...
...
@@ -19,12 +19,11 @@ class ArgumentarySerializerTest(TestCase):
organization
=
organization
)
Argumentary
.
objects
.
create
(
lang
=
'en'
,
text
=
'A pertinent argument'
,
title
=
'A title'
,
campaign
=
campaign
)
self
.
assertEqual
(
ArgumentarySerializer
(
Argumentary
.
objects
.
all
(),
many
=
True
).
data
,
[
OrderedDict
([(
'
lang'
,
'en'
),
(
'
text'
,
'A pertinent argument'
),
(
'title'
,
'A title'
)])])
self
.
assertEqual
(
ArgumentarySerializer
(
Argumentary
.
objects
.
all
(),
many
=
True
).
data
,
[
OrderedDict
([(
'text'
,
'A pertinent argument'
),
(
'title'
,
'A title'
)])])
class
CampaignContactSerializerTest
(
TestCase
):
def
test_to_representation
(
self
):
...
...
picampaign/campaign/test_views.py
View file @
4a7f5edc
...
...
@@ -17,7 +17,6 @@ class ViewSetTest(TestCase):
organization
=
self
.
organization
)
self
.
argumentary
=
Argumentary
.
objects
.
create
(
lang
=
'en'
,
text
=
'A pertinent argument'
,
title
=
'A title'
,
campaign
=
self
.
campaign
...
...
@@ -53,8 +52,8 @@ class ViewSetTest(TestCase):
client
=
APIClient
()
response
=
client
.
get
(
'/campaigns/%(cid)d/arguments/'
%
{
'cid'
:
self
.
campaign
.
id
},
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
b
'[{"
lang":"en","
text":"A pertinent argument","title":"A title"}]'
)
response
=
client
.
get
(
'/campaigns/%(cid)d/arguments/
%(lang)s/'
%
{
'cid'
:
self
.
campaign
.
id
,
'lang'
:
self
.
argumentary
.
lang
},
format
=
'json'
)
self
.
assertEqual
(
response
.
content
,
b
'[{"text":"A pertinent argument","title":"A title"}]'
)
response
=
client
.
get
(
'/campaigns/%(cid)d/arguments/
'
%
{
'cid'
:
self
.
campaign
.
id
},
format
=
'json'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
b
'
{"lang":"en","text":"A pertinent argument","title":"A title"}
'
)
self
.
assertEqual
(
response
.
content
,
b
'
[{"text":"A pertinent argument","title":"A title"}]
'
)
picampaign/campaign/views.py
View file @
4a7f5edc
...
...
@@ -35,8 +35,3 @@ class ArgumentaryViewSet(viewsets.ReadOnlyModelViewSet):
argumentaries
=
self
.
queryset
.
filter
(
campaign
=
campaign_pk
)
serializer
=
self
.
serializer_class
(
argumentaries
.
all
(),
many
=
True
)
return
Response
(
serializer
.
data
)
def
retrieve
(
self
,
request
,
pk
=
None
,
campaign_pk
=
None
):
argument
=
self
.
queryset
.
get
(
lang
=
pk
,
campaign
=
campaign_pk
)
serializer
=
self
.
serializer_class
(
argument
)
return
Response
(
serializer
.
data
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment