Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Robert
Commoning Engine
Commits
b6971bb9
Commit
b6971bb9
authored
Jun 17, 2020
by
Robert
Browse files
Add state to activities and needs
parent
0604df68
Changes
4
Hide whitespace changes
Inline
Side-by-side
commoning/migrations/0012_activity_state.py
0 → 100644
View file @
b6971bb9
# Generated by Django 2.2.13 on 2020-06-17 10:53
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'commoning'
,
'0011_auto_20200617_1003'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'activity'
,
name
=
'state'
,
field
=
models
.
IntegerField
(
choices
=
[(
0
,
'OPEN'
),
(
1
,
'ACTIVE'
),
(
2
,
'DONE'
)],
default
=
0
),
),
]
commoning/migrations/0013_need_is_satisfied.py
0 → 100644
View file @
b6971bb9
# Generated by Django 2.2.13 on 2020-06-17 10:55
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'commoning'
,
'0012_activity_state'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'need'
,
name
=
'is_satisfied'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
]
commoning/models.py
View file @
b6971bb9
from
enum
import
Enum
from
django.db
import
models
# TODO: with updating to django 3 replace by models.IntegerChoice
class
ActivityState
(
Enum
):
OPEN
=
0
ACTIVE
=
1
DONE
=
2
class
Activity
(
models
.
Model
):
creation_time
=
models
.
DateTimeField
(
auto_now_add
=
True
)
activity_pattern_url
=
models
.
URLField
()
state
=
models
.
IntegerField
(
choices
=
[(
s
.
value
,
s
.
name
)
for
s
in
ActivityState
],
default
=
ActivityState
.
OPEN
.
value
)
class
Assignment
(
models
.
Model
):
...
...
@@ -34,5 +45,7 @@ class Need(models.Model):
satisfying_activity
=
models
.
ForeignKey
(
'commoning.Activity'
,
on_delete
=
models
.
CASCADE
,
null
=
True
,
blank
=
True
)
is_satisfied
=
models
.
BooleanField
(
default
=
False
)
def
__str__
(
self
):
return
self
.
title
commoning/serializers.py
View file @
b6971bb9
...
...
@@ -6,7 +6,7 @@ from commoning.models import Activity, Assignment, Demand, Need
class
ActivitySerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
Meta
:
model
=
Activity
fields
=
[
'activity_pattern_url'
]
fields
=
[
'activity_pattern_url'
,
'state'
]
class
AssignmentSerializer
(
serializers
.
HyperlinkedModelSerializer
):
...
...
@@ -24,4 +24,4 @@ class DemandSerializer(serializers.HyperlinkedModelSerializer):
class
NeedSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
Meta
:
model
=
Need
fields
=
[
'title'
,
'description'
]
fields
=
[
'title'
,
'description'
,
'is_satisfied'
]
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