Skip to content

Commit 59f3dee

Browse files
authored
Revert duration field (#38)
Revert duration field to integer field
1 parent 9664f86 commit 59f3dee

6 files changed

Lines changed: 32 additions & 14 deletions

File tree

events/factories.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from datetime import timedelta
2-
31
import factory
42
import pytz
53

@@ -9,7 +7,7 @@
97

108
class EventFactory(factory.django.DjangoModelFactory):
119
name = factory.Faker("text", max_nb_chars=64)
12-
duration = factory.Faker("time_delta", end_datetime=timedelta(minutes=60))
10+
duration = factory.Faker("random_int", max=300)
1311
short_description = factory.Faker("text", max_nb_chars=64)
1412
description = factory.Faker("text")
1513
image = factory.Faker("file_name", extension="jpg")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 2.2.9 on 2020-01-24 08:27
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("events", "0004_event_duration"),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(model_name="event", name="duration",),
14+
migrations.AddField(
15+
model_name="event",
16+
name="duration",
17+
field=models.PositiveSmallIntegerField(
18+
blank=True, null=True, verbose_name="duration", help_text="In minutes"
19+
),
20+
),
21+
]

events/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class Event(TimestampedModel, TranslatableModel):
2727
choices=PARTICIPANT_AMOUNT_CHOICES,
2828
verbose_name=_("participants per invite"),
2929
)
30-
duration = models.DurationField(verbose_name=_("duration"), blank=True, null=True)
30+
duration = models.PositiveSmallIntegerField(
31+
verbose_name=_("duration"), blank=True, null=True, help_text=_("In minutes")
32+
)
3133
capacity_per_occurrence = models.PositiveSmallIntegerField(
3234
verbose_name=_("capacity per occurrence")
3335
)

events/schema.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def get_queryset(cls, queryset, info):
3232
def get_node(cls, info, id):
3333
return super().get_node(info, id)
3434

35-
def resolve_duration(self, info):
36-
return self.duration.total_seconds()
37-
3835

3936
class OccurrenceNode(DjangoObjectType):
4037
venue = graphene.Field(VenueNode)

events/tests/snapshots/snap_test_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"node": {
1515
"capacityPerOccurrence": 805,
1616
"createdAt": "2020-12-12T00:00:00+00:00",
17-
"duration": 1450.0,
17+
"duration": 181,
1818
"image": "spring.jpg",
1919
"occurrences": {
2020
"edges": [
@@ -58,7 +58,7 @@
5858
"event": {
5959
"capacityPerOccurrence": 805,
6060
"createdAt": "2020-12-12T00:00:00+00:00",
61-
"duration": 3041.0,
61+
"duration": 197,
6262
"image": "spring.jpg",
6363
"occurrences": {"edges": []},
6464
"participantsPerInvite": "FAMILY",
@@ -69,7 +69,7 @@
6969
Agree room laugh prevent make. Our very television beat at success decade.""",
7070
"languageCode": "FI",
7171
"name": "Free heart significant machine try.",
72-
"shortDescription": "Fall long respond draw military dog.",
72+
"shortDescription": "Perform in weight success answer.",
7373
}
7474
],
7575
"updatedAt": "2020-12-12T00:00:00+00:00",
@@ -85,7 +85,7 @@
8585
"node": {
8686
"event": {
8787
"capacityPerOccurrence": 805,
88-
"duration": 1450.0,
88+
"duration": 181,
8989
"image": "spring.jpg",
9090
"participantsPerInvite": "FAMILY",
9191
"publishedAt": "1986-02-27T01:22:35+00:00",
@@ -129,7 +129,7 @@
129129
"occurrence": {
130130
"event": {
131131
"capacityPerOccurrence": 805,
132-
"duration": 1450.0,
132+
"duration": 181,
133133
"image": "spring.jpg",
134134
"participantsPerInvite": "FAMILY",
135135
"publishedAt": "1986-02-27T01:22:35+00:00",

venues/tests/snapshots/snap_test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"node": {
1919
"event": {
2020
"capacityPerOccurrence": 805,
21-
"duration": 1450.0,
21+
"duration": 181,
2222
"image": "spring.jpg",
2323
"participantsPerInvite": "FAMILY",
2424
"publishedAt": "1986-02-27T01:22:35+00:00",
@@ -68,7 +68,7 @@
6868
"node": {
6969
"event": {
7070
"capacityPerOccurrence": 805,
71-
"duration": 1450.0,
71+
"duration": 181,
7272
"image": "spring.jpg",
7373
"participantsPerInvite": "FAMILY",
7474
"publishedAt": "1986-02-27T01:22:35+00:00",

0 commit comments

Comments
 (0)