Commit b6971bb9 authored by Robert's avatar Robert
Browse files

Add state to activities and needs

parent 0604df68
# 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),
),
]
# 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),
),
]
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
......@@ -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']
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment