diff --git a/README.md b/README.md index 3ec356e..432c61d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # 2077 Collective -Content management system written in Python(Django) and React.js +Content management system written in Python(Django) and Sveltekit ## Project Architecture diff --git a/server/apps/research/admin/article_admin.py b/server/apps/research/admin/article_admin.py index 4619f09..2846e6b 100644 --- a/server/apps/research/admin/article_admin.py +++ b/server/apps/research/admin/article_admin.py @@ -18,11 +18,12 @@ class ArticleAdmin(admin.ModelAdmin): form = ArticleForm fieldsets = [ ('Article Details', {'fields': ['title', 'slug', 'authors', 'acknowledgement', 'categories', 'thumb', 'content', 'summary', 'status', 'scheduled_publish_time']}), + ('Sponsorship Details', {'fields': ['is_sponsored', 'sponsor_color', 'sponsor_text_color', 'sponsor_padding']}), ] list_display = ('title', 'display_authors', 'status', 'views', 'display_categories', 'min_read', 'created_at', 'scheduled_publish_time') search_fields = ('title', 'authors__user__username', 'authors__twitter_username', 'content') list_per_page = 25 - list_filter = ('authors', 'status', 'categories', 'created_at') + list_filter = ('authors', 'status', 'categories', 'created_at', 'is_sponsored') readonly_fields = ('views',) list_editable = ('status',) diff --git a/server/apps/research/migrations/0006_article_is_sponsored_article_sponsor_color_and_more.py b/server/apps/research/migrations/0006_article_is_sponsored_article_sponsor_color_and_more.py new file mode 100644 index 0000000..67414ad --- /dev/null +++ b/server/apps/research/migrations/0006_article_is_sponsored_article_sponsor_color_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.8 on 2024-10-23 08:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('research', '0005_article_table_of_contents'), + ] + + operations = [ + migrations.AddField( + model_name='article', + name='is_sponsored', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='article', + name='sponsor_color', + field=models.CharField(default='#FF0420', max_length=7), + ), + migrations.AddField( + model_name='article', + name='sponsor_text_color', + field=models.CharField(default='#000000', max_length=7), + ), + ] diff --git a/server/apps/research/migrations/0007_alter_article_sponsor_color_and_more.py b/server/apps/research/migrations/0007_alter_article_sponsor_color_and_more.py new file mode 100644 index 0000000..9faacb3 --- /dev/null +++ b/server/apps/research/migrations/0007_alter_article_sponsor_color_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.8 on 2024-10-23 10:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('research', '0006_article_is_sponsored_article_sponsor_color_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='sponsor_color', + field=models.CharField(default='#FF0420 !important', max_length=7), + ), + migrations.AlterField( + model_name='article', + name='sponsor_text_color', + field=models.CharField(default='#000000 !important', max_length=7), + ), + ] diff --git a/server/apps/research/migrations/0008_alter_article_sponsor_color_and_more.py b/server/apps/research/migrations/0008_alter_article_sponsor_color_and_more.py new file mode 100644 index 0000000..b229923 --- /dev/null +++ b/server/apps/research/migrations/0008_alter_article_sponsor_color_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.8 on 2024-10-23 10:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('research', '0007_alter_article_sponsor_color_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='sponsor_color', + field=models.CharField(default='bg-red-700 !important', max_length=7), + ), + migrations.AlterField( + model_name='article', + name='sponsor_text_color', + field=models.CharField(default='#bg-gray-700 !important', max_length=7), + ), + ] diff --git a/server/apps/research/migrations/0009_alter_article_sponsor_text_color.py b/server/apps/research/migrations/0009_alter_article_sponsor_text_color.py new file mode 100644 index 0000000..468a544 --- /dev/null +++ b/server/apps/research/migrations/0009_alter_article_sponsor_text_color.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.8 on 2024-10-23 10:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('research', '0008_alter_article_sponsor_color_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='article', + name='sponsor_text_color', + field=models.CharField(default='text-gray-700 !important', max_length=7), + ), + ] diff --git a/server/apps/research/migrations/0010_article_sponsor_padding_alter_article_sponsor_color_and_more.py b/server/apps/research/migrations/0010_article_sponsor_padding_alter_article_sponsor_color_and_more.py new file mode 100644 index 0000000..c6d0e62 --- /dev/null +++ b/server/apps/research/migrations/0010_article_sponsor_padding_alter_article_sponsor_color_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.8 on 2024-10-23 11:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('research', '0009_alter_article_sponsor_text_color'), + ] + + operations = [ + migrations.AddField( + model_name='article', + name='sponsor_padding', + field=models.CharField(default='px-4 py-6', max_length=20), + ), + migrations.AlterField( + model_name='article', + name='sponsor_color', + field=models.CharField(default='#FF0420', max_length=7), + ), + migrations.AlterField( + model_name='article', + name='sponsor_text_color', + field=models.CharField(default='#000000', max_length=7), + ), + ] diff --git a/server/apps/research/models/article.py b/server/apps/research/models/article.py index 3eef175..efb6ca0 100644 --- a/server/apps/research/models/article.py +++ b/server/apps/research/models/article.py @@ -34,6 +34,10 @@ class Article(BaseModel): status = models.CharField(max_length=10, choices=options, default='draft', db_index=True) scheduled_publish_time = models.DateTimeField(null=True, blank=True, db_index=True) table_of_contents = models.JSONField(default=list, blank=True) + is_sponsored = models.BooleanField(default=False) + sponsor_color = models.CharField(max_length=7, default="#FF0420") + sponsor_text_color = models.CharField(max_length=7, default="#000000") + sponsor_padding = models.CharField(max_length=20, default="px-4 py-6") objects = models.Manager() post_objects = ArticleObjects() diff --git a/server/apps/research/serializers/article_serializer.py b/server/apps/research/serializers/article_serializer.py index 1feb70c..7bb2ad2 100644 --- a/server/apps/research/serializers/article_serializer.py +++ b/server/apps/research/serializers/article_serializer.py @@ -27,7 +27,8 @@ class Meta: fields = [ 'id', 'slug', 'title', 'authors', 'thumb', 'categories', 'summary', 'acknowledgement', 'content', 'min_read', 'status', 'views', - 'created_at', 'updated_at', 'scheduled_publish_time', 'table_of_contents' + 'created_at', 'updated_at', 'scheduled_publish_time', 'table_of_contents', + 'is_sponsored', 'sponsor_color', 'sponsor_text_color', 'sponsor_padding' ] class ArticleCreateUpdateSerializer(serializers.ModelSerializer): @@ -37,7 +38,7 @@ class ArticleCreateUpdateSerializer(serializers.ModelSerializer): class Meta: model = Article - fields = ['title', 'slug', 'categories', 'thumb', 'content', 'summary', 'acknowledgement', 'status', 'authors', 'scheduled_publish_time'] + fields = ['title', 'slug', 'categories', 'thumb', 'content', 'summary', 'acknowledgement', 'status', 'authors', 'scheduled_publish_time', 'is_sponsored', 'sponsor_color', 'sponsor_text_color', 'sponsor_padding'] def create(self, validated_data: dict) -> Article: """Create a new article instance.""" diff --git a/server/media/images/Screenshot_from_2024-10-23_05-08-02.png b/server/media/images/Screenshot_from_2024-10-23_05-08-02.png new file mode 100644 index 0000000..2541f16 Binary files /dev/null and b/server/media/images/Screenshot_from_2024-10-23_05-08-02.png differ