From c4036c9a4706081f191b611abece90ef201dcb82 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Wed, 16 Feb 2022 23:21:38 -0400
Subject: [PATCH] Rename fields from Category, FundingCategory, MusicFocus,
 Topic and Type

---
 fixtures/program/category.json        | 16 +++++++-------
 fixtures/program/fundingcategory.json |  2 +-
 fixtures/program/musicfocus.json      | 20 +++++++++---------
 fixtures/program/topic.json           | 10 ++++-----
 fixtures/program/type.json            | 14 ++++++-------
 program/models.py                     | 30 +++++++++++++--------------
 program/serializers.py                | 20 ++++++++++++++++++
 7 files changed, 66 insertions(+), 46 deletions(-)

diff --git a/fixtures/program/category.json b/fixtures/program/category.json
index 67b76968..d41ea21d 100644
--- a/fixtures/program/category.json
+++ b/fixtures/program/category.json
@@ -3,7 +3,7 @@
     "model": "program.category",
     "pk": 1,
     "fields": {
-      "category": "Interkulturell",
+      "name": "Interkulturell",
       "abbrev": "I",
       "slug": "interkulturell",
       "is_active": true,
@@ -14,7 +14,7 @@
     "model": "program.category",
     "pk": 2,
     "fields": {
-      "category": "Lokalbezug",
+      "name": "Lokalbezug",
       "abbrev": "L",
       "slug": "lokalbezug",
       "is_active": true,
@@ -25,7 +25,7 @@
     "model": "program.category",
     "pk": 3,
     "fields": {
-      "category": "Minderheiten",
+      "name": "Minderheiten",
       "abbrev": "Mi",
       "slug": "minderheiten",
       "is_active": true,
@@ -36,7 +36,7 @@
     "model": "program.category",
     "pk": 4,
     "fields": {
-      "category": "Wiederholung",
+      "name": "Wiederholung",
       "abbrev": "W",
       "slug": "wiederholung",
       "is_active": true,
@@ -47,7 +47,7 @@
     "model": "program.category",
     "pk": 5,
     "fields": {
-      "category": "Mehr-/Fremdsprachig",
+      "name": "Mehr-/Fremdsprachig",
       "abbrev": "M",
       "slug": "mehr-fremdsprachig",
       "is_active": true,
@@ -58,7 +58,7 @@
     "model": "program.category",
     "pk": 6,
     "fields": {
-      "category": "Frauenschwerpunkt",
+      "name": "Frauenschwerpunkt",
       "abbrev": "F",
       "slug": "frauenschwerpunkt",
       "is_active": true,
@@ -69,7 +69,7 @@
     "model": "program.category",
     "pk": 7,
     "fields": {
-      "category": "Österreichische Musik",
+      "name": "Österreichische Musik",
       "abbrev": "Ö",
       "slug": "osterreichische-musik",
       "is_active": true,
@@ -80,7 +80,7 @@
     "model": "program.category",
     "pk": 8,
     "fields": {
-      "category": "Sendungsübernahme",
+      "name": "Sendungsübernahme",
       "abbrev": "U",
       "slug": "sendungsubernahme",
       "is_active": true,
diff --git a/fixtures/program/fundingcategory.json b/fixtures/program/fundingcategory.json
index 72d5a689..8e4b28f5 100644
--- a/fixtures/program/fundingcategory.json
+++ b/fixtures/program/fundingcategory.json
@@ -3,7 +3,7 @@
     "model": "program.fundingcategory",
     "pk": 1,
     "fields": {
-      "fundingcategory": "Standard",
+      "name": "Standard",
       "abbrev": "S",
       "slug": "standard",
       "is_active": true
diff --git a/fixtures/program/musicfocus.json b/fixtures/program/musicfocus.json
index b2ef22a6..26a5922f 100644
--- a/fixtures/program/musicfocus.json
+++ b/fixtures/program/musicfocus.json
@@ -3,7 +3,7 @@
     "model": "program.musicfocus",
     "pk": 1,
     "fields": {
-      "focus": "Jazz",
+      "name": "Jazz",
       "abbrev": "J",
       "slug": "jazz",
       "is_active": true
@@ -13,7 +13,7 @@
     "model": "program.musicfocus",
     "pk": 2,
     "fields": {
-      "focus": "Volksmusik/Folk",
+      "name": "Volksmusik/Folk",
       "abbrev": "V",
       "slug": "volksmusik-folk",
       "is_active": true
@@ -23,7 +23,7 @@
     "model": "program.musicfocus",
     "pk": 3,
     "fields": {
-      "focus": "Experimentelle Musik",
+      "name": "Experimentelle Musik",
       "abbrev": "Ex",
       "slug": "expermentelle-musik",
       "is_active": true
@@ -33,7 +33,7 @@
     "model": "program.musicfocus",
     "pk": 4,
     "fields": {
-      "focus": "Rock/Indie",
+      "name": "Rock/Indie",
       "abbrev": "R",
       "slug": "rock-indie",
       "is_active": true
@@ -43,7 +43,7 @@
     "model": "program.musicfocus",
     "pk": 5,
     "fields": {
-      "focus": "Metal/Hardrock",
+      "name": "Metal/Hardrock",
       "abbrev": "M",
       "slug": "metal-hardrock",
       "is_active": true
@@ -53,7 +53,7 @@
     "model": "program.musicfocus",
     "pk": 6,
     "fields": {
-      "focus": "Electronic",
+      "name": "Electronic",
       "abbrev": "E",
       "slug": "electronic",
       "is_active": true
@@ -63,7 +63,7 @@
     "model": "program.musicfocus",
     "pk": 7,
     "fields": {
-      "focus": "Klassik",
+      "name": "Klassik",
       "abbrev": "K",
       "slug": "klassik",
       "is_active": true
@@ -73,7 +73,7 @@
     "model": "program.musicfocus",
     "pk": 8,
     "fields": {
-      "focus": "Oldies",
+      "name": "Oldies",
       "abbrev": "O",
       "slug": "oldies",
       "is_active": true
@@ -83,7 +83,7 @@
     "model": "program.musicfocus",
     "pk": 9,
     "fields": {
-      "focus": "Reggae/Ska",
+      "name": "Reggae/Ska",
       "abbrev": "Re",
       "slug": "reggae-ska",
       "is_active": true
@@ -93,7 +93,7 @@
     "model": "program.musicfocus",
     "pk": 10,
     "fields": {
-      "focus": "Hiphop",
+      "name": "Hiphop",
       "abbrev": "H",
       "slug": "hiphop",
       "is_active": true
diff --git a/fixtures/program/topic.json b/fixtures/program/topic.json
index 5969364f..0d69ffbc 100644
--- a/fixtures/program/topic.json
+++ b/fixtures/program/topic.json
@@ -3,7 +3,7 @@
     "model": "program.topic",
     "pk": 1,
     "fields": {
-      "topic": "Politik/Gesellschaft",
+      "name": "Politik/Gesellschaft",
       "abbrev": "P",
       "slug": "politik-gesellschaft",
       "is_active": true
@@ -13,7 +13,7 @@
     "model": "program.topic",
     "pk": 2,
     "fields": {
-      "topic": "Natur/Klima/Tiere",
+      "name": "Natur/Klima/Tiere",
       "abbrev": "N",
       "slug": "natur-klima-tiere",
       "is_active": true
@@ -23,7 +23,7 @@
     "model": "program.topic",
     "pk": 3,
     "fields": {
-      "topic": "Kultur/Kunst",
+      "name": "Kultur/Kunst",
       "abbrev": "K",
       "slug": "kultur-kunst",
       "is_active": true
@@ -33,7 +33,7 @@
     "model": "program.topic",
     "pk": 4,
     "fields": {
-      "topic": "Soziales",
+      "name": "Soziales",
       "abbrev": "S",
       "slug": "soziales",
       "is_active": true
@@ -43,7 +43,7 @@
     "model": "program.topic",
     "pk": 5,
     "fields": {
-      "topic": "Wissenschaft/Philosophie",
+      "name": "Wissenschaft/Philosophie",
       "abbrev": "W",
       "slug": "wissenschaft-philosophie",
       "is_active": true
diff --git a/fixtures/program/type.json b/fixtures/program/type.json
index 8b8c1dc7..2ca58399 100644
--- a/fixtures/program/type.json
+++ b/fixtures/program/type.json
@@ -3,7 +3,7 @@
     "model": "program.type",
     "pk": 1,
     "fields": {
-      "type": "Talk",
+      "name": "Talk",
       "slug": "talk",
       "is_active": true
     }
@@ -12,7 +12,7 @@
     "model": "program.type",
     "pk": 2,
     "fields": {
-      "type": "Musiksendung",
+      "name": "Musiksendung",
       "slug": "musiksendung",
       "is_active": true
     }
@@ -21,7 +21,7 @@
     "model": "program.type",
     "pk": 3,
     "fields": {
-      "type": "Unmoderiertes Musikprogramm",
+      "name": "Unmoderiertes Musikprogramm",
       "slug": "unmoderiertes-musikprogramm",
       "is_active": true
     }
@@ -30,7 +30,7 @@
     "model": "program.type",
     "pk": 4,
     "fields": {
-      "type": "Feature/Magazin",
+      "name": "Feature/Magazin",
       "slug": "feature-magazin",
       "is_active": true
     }
@@ -39,7 +39,7 @@
     "model": "program.type",
     "pk": 5,
     "fields": {
-      "type": "Experimentell",
+      "name": "Experimentell",
       "slug": "experimentell",
       "is_active": true
     }
@@ -48,7 +48,7 @@
     "model": "program.type",
     "pk": 6,
     "fields": {
-      "type": "Hörspiel/Literatur",
+      "name": "Hörspiel/Literatur",
       "slug": "horspiel-literatur",
       "is_active": true
     }
@@ -57,7 +57,7 @@
     "model": "program.type",
     "pk": 7,
     "fields": {
-      "type": "Vortrag/Diskussion",
+      "name": "Vortrag/Diskussion",
       "slug": "vortrag-diskussion",
       "is_active": true
     }
diff --git a/program/models.py b/program/models.py
index fe9dafa7..0efbb998 100644
--- a/program/models.py
+++ b/program/models.py
@@ -36,78 +36,78 @@ from program.utils import parse_datetime, parse_date, parse_time
 
 
 class Type(models.Model):
-    type = models.CharField(_("Type"), max_length=32)
+    name = models.CharField(_("Type"), max_length=32)
     slug = models.SlugField(_("Slug"), max_length=32, unique=True)
     is_active = models.BooleanField(_("Is active?"), default=True)
 
     class Meta:
-        ordering = ('type',)
+        ordering = ('name',)
         verbose_name = _("Type")
         verbose_name_plural = _("Types")
 
     def __str__(self):
-        return '%s' % self.type
+        return '%s' % self.name
 
 
 class Category(models.Model):
-    category = models.CharField(_("Category"), max_length=32)
+    name = models.CharField(_("Category"), max_length=32)
     abbrev = models.CharField(_("Abbreviation"), max_length=4, unique=True)
     slug = models.SlugField(_("Slug"), max_length=32, unique=True)
     is_active = models.BooleanField(_("Is active?"), default=True)
     description = models.TextField(_("Description"), blank=True)
 
     class Meta:
-        ordering = ('category',)
+        ordering = ('name',)
         verbose_name = _("Category")
         verbose_name_plural = _("Categories")
 
     def __str__(self):
-        return '%s' % self.category
+        return '%s' % self.name
 
 
 class Topic(models.Model):
-    topic = models.CharField(_("Topic"), max_length=32)
+    name = models.CharField(_("Topic"), max_length=32)
     abbrev = models.CharField(_("Abbreviation"), max_length=4, unique=True)
     slug = models.SlugField(_("Slug"), max_length=32, unique=True)
     is_active = models.BooleanField(_("Is active?"), default=True)
 
     class Meta:
-        ordering = ('topic',)
+        ordering = ('name',)
         verbose_name = _("Topic")
         verbose_name_plural = _("Topics")
 
     def __str__(self):
-        return '%s' % self.topic
+        return '%s' % self.name
 
 
 class MusicFocus(models.Model):
-    focus = models.CharField(_("Focus"), max_length=32)
+    name = models.CharField(_("Focus"), max_length=32)
     abbrev = models.CharField(_("Abbreviation"), max_length=4, unique=True)
     slug = models.SlugField(_("Slug"), max_length=32, unique=True)
     is_active = models.BooleanField(_("Is active?"), default=True)
 
     class Meta:
-        ordering = ('focus',)
+        ordering = ('name',)
         verbose_name = _("Music focus")
         verbose_name_plural = _("Music focus")
 
     def __str__(self):
-        return '%s' % self.focus
+        return '%s' % self.name
 
 
 class FundingCategory(models.Model):
-    fundingcategory = models.CharField(_("Funding Category"), max_length=32)
+    name = models.CharField(_("Funding Category"), max_length=32)
     abbrev = models.CharField(_("Abbreviation"), max_length=4, unique=True)
     slug = models.SlugField(_("Slug"), max_length=32, unique=True)
     is_active = models.BooleanField(_("Is active?"), default=True)
 
     class Meta:
-        ordering = ('fundingcategory',)
+        ordering = ('name',)
         verbose_name = _("Funding Category")
         verbose_name_plural = _("Funding Categories")
 
     def __str__(self):
-        return '%s' % self.fundingcategory
+        return '%s' % self.name
 
 
 class Language(models.Model):
diff --git a/program/serializers.py b/program/serializers.py
index 5af1f180..ad49570e 100644
--- a/program/serializers.py
+++ b/program/serializers.py
@@ -90,8 +90,12 @@ class UserSerializer(serializers.ModelSerializer):
 
 
 class CategorySerializer(serializers.ModelSerializer):
+    # TODO: remove this when the dashboard is updated
+    category = serializers.CharField(source='name')
+
     class Meta:
         model = Category
+        # TODO: replace `category` with `name` when the dashboard is updated
         fields = ('category', 'abbrev', 'slug', 'is_active', 'description')
 
 
@@ -162,26 +166,42 @@ class LanguageSerializer(serializers.ModelSerializer):
 
 
 class TopicSerializer(serializers.ModelSerializer):
+    # TODO: remove this when the dashboard is updated
+    topic = serializers.CharField(source='name')
+
     class Meta:
         model = Topic
+        # TODO: replace `topic` with `name` when the dashboard is updated
         fields = ('topic', 'abbrev', 'slug', 'is_active')
 
 
 class MusicFocusSerializer(serializers.ModelSerializer):
+    # TODO: remove this when the dashboard is updated
+    focus = serializers.CharField(source='name')
+
     class Meta:
         model = MusicFocus
+        # TODO: replace `focus` with `name` when the dashboard is updated
         fields = ('focus', 'abbrev', 'slug', 'is_active')
 
 
 class TypeSerializer(serializers.ModelSerializer):
+    # TODO: remove this when the dashboard is updated
+    type = serializers.CharField(source='name')
+
     class Meta:
         model = Type
+        # TODO: replace `type` with `name` when the dashboard is updated
         fields = ('type', 'slug', 'is_active')
 
 
 class FundingCategorySerializer(serializers.ModelSerializer):
+    # TODO: remove this when the dashboard is updated
+    fundingcategory = serializers.CharField(source='name')
+
     class Meta:
         model = FundingCategory
+        # TODO: replace `fundingcategory` with `name` when the dashboard is updated
         fields = ('fundingcategory', 'abbrev', 'slug', 'is_active')
 
 
-- 
GitLab