diff --git a/officialWebsite/resources/migrations/0003_auto_20201020_1805.py b/officialWebsite/resources/migrations/0003_auto_20201020_1805.py new file mode 100644 index 00000000..878b81a8 --- /dev/null +++ b/officialWebsite/resources/migrations/0003_auto_20201020_1805.py @@ -0,0 +1,43 @@ +# Generated by Django 3.1.1 on 2020-10-20 18:05 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("resources", "0002_auto_20201007_2250"), + ] + + operations = [ + migrations.RenameField( + model_name="resource", + old_name="title", + new_name="topic", + ), + migrations.RenameField( + model_name="resource", + old_name="docs", + new_name="url", + ), + migrations.RemoveField( + model_name="resource", + name="description", + ), + migrations.RemoveField( + model_name="resource", + name="headline_event", + ), + migrations.RemoveField( + model_name="resource", + name="image", + ), + migrations.RemoveField( + model_name="resource", + name="info", + ), + migrations.RemoveField( + model_name="resource", + name="link", + ), + ] diff --git a/officialWebsite/resources/migrations/0004_auto_20201020_1902.py b/officialWebsite/resources/migrations/0004_auto_20201020_1902.py new file mode 100644 index 00000000..f340e33c --- /dev/null +++ b/officialWebsite/resources/migrations/0004_auto_20201020_1902.py @@ -0,0 +1,41 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:02 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ("resources", "0003_auto_20201020_1805"), + ] + + operations = [ + migrations.CreateModel( + name="Topic", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("topic", models.CharField(default="Human", max_length=255)), + ], + ), + migrations.AlterField( + model_name="resource", + name="url", + field=models.URLField(default="Human", max_length=255), + ), + migrations.AlterField( + model_name="resource", + name="topic", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="resources.topic" + ), + ), + ] diff --git a/officialWebsite/resources/migrations/0005_auto_20201020_1949.py b/officialWebsite/resources/migrations/0005_auto_20201020_1949.py new file mode 100644 index 00000000..a0333193 --- /dev/null +++ b/officialWebsite/resources/migrations/0005_auto_20201020_1949.py @@ -0,0 +1,26 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("events", "0007_auto_20200515_1214"), + ("resources", "0004_auto_20201020_1902"), + ] + + operations = [ + migrations.RemoveField( + model_name="resource", + name="topic", + ), + migrations.AddField( + model_name="resource", + name="topic", + field=models.ManyToManyField(blank=True, to="events.Topic"), + ), + migrations.DeleteModel( + name="Topic", + ), + ] diff --git a/officialWebsite/resources/migrations/0006_auto_20201020_1954.py b/officialWebsite/resources/migrations/0006_auto_20201020_1954.py new file mode 100644 index 00000000..3488b7a1 --- /dev/null +++ b/officialWebsite/resources/migrations/0006_auto_20201020_1954.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.1 on 2020-10-20 19:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("resources", "0005_auto_20201020_1949"), + ] + + operations = [ + migrations.AlterField( + model_name="resource", + name="name", + field=models.CharField(default="", max_length=255), + ), + migrations.AlterField( + model_name="resource", + name="url", + field=models.URLField(default=""), + ), + ] diff --git a/officialWebsite/resources/models.py b/officialWebsite/resources/models.py index 3bb0ff30..afee6fbd 100644 --- a/officialWebsite/resources/models.py +++ b/officialWebsite/resources/models.py @@ -1,15 +1,11 @@ from django.db import models +from officialWebsite.events.models import Topic class Resource(models.Model): - name = models.CharField(max_length=255, blank=False, default="Human") - title = models.CharField(max_length=255, default="Human") - info = models.TextField(max_length=255, default="Human") - description = models.TextField(max_length=255, default="Human") - link = models.URLField(blank=True) - docs = models.URLField(blank=True) - headline_event = models.BooleanField(default=False) - image = models.ImageField(upload_to="resource-images/", blank=True) + name = models.CharField(max_length=255, blank=False, default="") + url = models.URLField(blank=False, default="") + topic = models.ManyToManyField(Topic, blank=True) def __str__(self): return self.name diff --git a/officialWebsite/resources/serializers.py b/officialWebsite/resources/serializers.py index ca39cd8b..2eb32b78 100644 --- a/officialWebsite/resources/serializers.py +++ b/officialWebsite/resources/serializers.py @@ -7,5 +7,5 @@ class ResourceSerializer(serializers.ModelSerializer): class Meta: model = models.Resource - fields = ("id", "name", "link") + fields = ("id", "name", "url", "topic") read_only_fields = ("id",)