Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
rb-25 committed Apr 28, 2024
2 parents a2d7480 + 0b9c04f commit 7da2ed6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
6 changes: 6 additions & 0 deletions student_welfare_backend/student_welfare_backend/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class OrganizationAdmin(admin.ModelAdmin):
"sub_type",
]
list_filter = ["type", "sub_type"]
search_fields = ["name", "type", "sub_type"]


@admin.register(UserOrganizationRelation)
Expand All @@ -29,6 +30,7 @@ class UserOrganizationRelationAdmin(admin.ModelAdmin):
"position"
]
list_filter = ["role", "position"]
search_fields = ["user__name", "organization__name", "role", "position"]


@admin.register(Event)
Expand All @@ -43,6 +45,7 @@ class EventAdmin(admin.ModelAdmin):
"end_time",
]
list_filter = ["organizing_body"]
search_fields = ["name", "organizing_body__name"]


@admin.register(Spotlight)
Expand All @@ -56,6 +59,7 @@ class SpotlightAdmin(admin.ModelAdmin):
"hightlight_type",
]
list_filter = ["name", "hightlight_type"]
search_fields = ["name", "hightlight_type"]


@admin.register(Newsletter)
Expand All @@ -69,6 +73,7 @@ class NewsletterAdmin(admin.ModelAdmin):
"link"
]
list_filter = ["year", "month"]
search_fields = ["year", "month"]


@admin.register(FAQ)
Expand All @@ -81,6 +86,7 @@ class FAQAdmin(admin.ModelAdmin):
"answer"
]
search_fields = ["question", "answer"]
ordering = ["question"]


@admin.register(SpecialFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class OrganizationViewSet(ReadOnlyModelViewSet):
search_fields = ["name"]
ordering_fields = ["name"]
ordering = ["name"]
special_organization_types = ["student_welfare", "student_council", "greviance_cell", "counseling_division"]
special_organization_types = ["student_welfare", "student_council", "grievance_cell", "counselling_division"]

def get_serializer_class(self):
if (self.action == "list") and (
Expand All @@ -72,7 +72,7 @@ def get(request):
status=status.HTTP_400_BAD_REQUEST,
)

if organization_type not in ["student_welfare", "student_council", "greviance_cell"]:
if organization_type not in ["student_welfare", "student_council", "grievance_cell"]:
return Response(
{"detail": "Invalid type parameter"},
status=status.HTTP_400_BAD_REQUEST,
Expand Down Expand Up @@ -103,7 +103,7 @@ def get(request):
status=status.HTTP_400_BAD_REQUEST,
)

if organization_type in ["student_welfare", "student_council", "greviance_cell", "counseling_division"]:
if organization_type in ["student_welfare", "student_council", "grievance_cell", "counselling_division"]:
return Response(
{"detail": "Special organizations type parameter not allowed"},
status=status.HTTP_400_BAD_REQUEST,
Expand Down Expand Up @@ -132,7 +132,7 @@ class OrganizationAdminViewSet(ModelViewSet):
search_fields = ["name"]
ordering_fields = ["name"]
ordering = ["name"]
special_organization_types = ["student_welfare", "student_council", "greviance_cell"]
special_organization_types = ["student_welfare", "student_council", "grievance_cell"]

def get_serializer_class(self):
if (self.action == "list") and (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.10 on 2024-04-28 06:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0019_alter_organization_description'),
]

operations = [
migrations.AlterField(
model_name='organization',
name='type',
field=models.CharField(choices=[('student_welfare', 'Student Welfare'), ('student_council', 'Student Council'), ('club', 'Club'), ('chapter', 'Chapter'), ('team', 'Team'), ('greviance_cell', 'Greviance Cell'), ('counselling_division', 'Counselling Division'), ('other', 'Other')], default='club', max_length=50, verbose_name='Type'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.10 on 2024-04-28 06:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0020_alter_organization_type'),
]

operations = [
migrations.AlterField(
model_name='organization',
name='type',
field=models.CharField(choices=[('student_welfare', 'Student Welfare'), ('student_council', 'Student Council'), ('club', 'Club'), ('chapter', 'Chapter'), ('team', 'Team'), ('grievance_cell', 'Grievance Cell'), ('counselling_division', 'Counselling Division'), ('other', 'Other')], default='club', max_length=50, verbose_name='Type'),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Organization(models.Model):
("club", "Club"),
("chapter", "Chapter"),
("team", "Team"),
("greviance_cell", "Greviance Cell"),
("counseling_division", "Counseling Division"),
("grievance_cell", "Grievance Cell"),
("counselling_division", "Counselling Division"),
("other", "Other"),
]

Expand Down

0 comments on commit 7da2ed6

Please sign in to comment.