Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamza Touizrat
oser-backend
Commits
38e5f5b9
Commit
38e5f5b9
authored
7 years ago
by
florimondmanca
Browse files
Options
Downloads
Patches
Plain Diff
add drag-n-drop ordering on sections and questions
parent
5fca08a2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
dynamicforms/admin.py
+3
-2
3 additions, 2 deletions
dynamicforms/admin.py
dynamicforms/migrations/0015_auto_20180616_2136.py
+31
-0
31 additions, 0 deletions
dynamicforms/migrations/0015_auto_20180616_2136.py
dynamicforms/models.py
+18
-0
18 additions, 0 deletions
dynamicforms/models.py
with
52 additions
and
2 deletions
dynamicforms/admin.py
+
3
−
2
View file @
38e5f5b9
"""
Dynamic forms admin panels.
"""
from
django.contrib
import
admin
from
adminsortable2.admin
import
SortableInlineAdminMixin
from
.models
import
Answer
,
File
,
Form
,
FormEntry
,
Question
,
Section
from
.views
import
download_multiple_forms_entries
class
SectionInline
(
admin
.
StackedInline
):
class
SectionInline
(
SortableInlineAdminMixin
,
admin
.
StackedInline
):
"""
Inline for sections.
"""
model
=
Section
extra
=
0
class
QuestionInline
(
admin
.
StackedInline
):
class
QuestionInline
(
SortableInlineAdminMixin
,
admin
.
StackedInline
):
"""
Inline for questions.
"""
model
=
Question
...
...
This diff is collapsed.
Click to expand it.
dynamicforms/migrations/0015_auto_20180616_2136.py
0 → 100644
+
31
−
0
View file @
38e5f5b9
# Generated by Django 2.0.6 on 2018-06-16 19:36
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
dynamicforms
'
,
'
0014_auto_20180616_1812
'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'
question
'
,
options
=
{
'
ordering
'
:
(
'
order
'
,)},
),
migrations
.
AlterModelOptions
(
name
=
'
section
'
,
options
=
{
'
ordering
'
:
(
'
order
'
,)},
),
migrations
.
AddField
(
model_name
=
'
question
'
,
name
=
'
order
'
,
field
=
models
.
PositiveIntegerField
(
default
=
0
,
verbose_name
=
'
position
'
),
),
migrations
.
AddField
(
model_name
=
'
section
'
,
name
=
'
order
'
,
field
=
models
.
PositiveIntegerField
(
default
=
0
,
verbose_name
=
'
position
'
),
),
]
This diff is collapsed.
Click to expand it.
dynamicforms/models.py
+
18
−
0
View file @
38e5f5b9
...
...
@@ -59,8 +59,17 @@ class Section(models.Model):
verbose_name
=
'
formulaire
'
,
help_text
=
"
Formulaire associé à la section.
"
)
order
=
models
.
PositiveIntegerField
(
'
position
'
,
default
=
0
,
blank
=
False
,
null
=
False
)
questions
:
models
.
Manager
class
Meta
:
# noqa
ordering
=
(
'
order
'
,)
def
__str__
(
self
):
return
str
(
self
.
title
)
...
...
@@ -108,8 +117,17 @@ class Question(models.Model):
verbose_name
=
'
section
'
,
help_text
=
"
Section de formulaire associée à la question.
"
)
order
=
models
.
PositiveIntegerField
(
'
position
'
,
default
=
0
,
blank
=
False
,
null
=
False
)
answers
:
models
.
Manager
class
Meta
:
# noqa
ordering
=
(
'
order
'
,)
def
__str__
(
self
)
->
str
:
return
f
'
{
self
.
text
}{
self
.
required
and
"
*
"
or
""
}
'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment