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
memopol
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
Porkepix
memopol
Commits
8e971b10
Commit
8e971b10
authored
Oct 12, 2016
by
Nicolas Joyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use autocomplete for themes in position form
parent
2a3afb72
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
1 deletion
+22
-1
src/memopol/urls.py
src/memopol/urls.py
+8
-0
src/memopol/views/autocomplete.py
src/memopol/views/autocomplete.py
+11
-0
src/representatives_positions/forms.py
src/representatives_positions/forms.py
+3
-1
No files found.
src/memopol/urls.py
View file @
8e971b10
...
...
@@ -8,6 +8,7 @@ from views.home import HomeView
from
views.autocomplete
import
(
ProposalAutocomplete
,
RepresentativeAutocomplete
,
ThemeAutocomplete
,
)
from
views.charts
import
ThemeScoresJSONView
,
ChamberScoresJSONView
...
...
@@ -132,12 +133,19 @@ urlpatterns = [
ProposalAutocomplete
.
as_view
(),
name
=
'proposal-autocomplete'
,
),
url
(
r
'^autocomplete/representative/$'
,
RepresentativeAutocomplete
.
as_view
(),
name
=
'representative-autocomplete'
,
),
url
(
r
'^autocomplete/theme/$'
,
ThemeAutocomplete
.
as_view
(),
name
=
'theme-autocomplete'
,
),
# Theme list
...
...
src/memopol/views/autocomplete.py
View file @
8e971b10
...
...
@@ -6,6 +6,7 @@ from django.db.models import Q
from
representatives.models
import
Representative
from
representatives_votes.models
import
Proposal
from
memopol_themes.models
import
Theme
class
RepresentativeAutocomplete
(
autocomplete
.
Select2QuerySetView
):
...
...
@@ -32,3 +33,13 @@ class ProposalAutocomplete(autocomplete.Select2QuerySetView):
)
return
qs
class
ThemeAutocomplete
(
autocomplete
.
Select2QuerySetView
):
def
get_queryset
(
self
):
qs
=
Theme
.
objects
.
all
()
if
self
.
q
:
qs
=
qs
.
filter
(
name__icontains
=
self
.
q
)
return
qs
src/representatives_positions/forms.py
View file @
8e971b10
...
...
@@ -11,7 +11,9 @@ class PositionForm(forms.ModelForm):
themes
=
forms
.
models
.
ModelMultipleChoiceField
(
queryset
=
Theme
.
objects
.
all
(),
required
=
False
,
widget
=
forms
.
CheckboxSelectMultiple
widget
=
ModelSelect2Multiple
(
url
=
'theme-autocomplete'
,
)
)
class
Meta
:
...
...
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