generated from GDGVIT/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
235 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
student_welfare_backend/student_welfare_backend/core/api/views/faqs.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet | ||
from rest_framework.filters import SearchFilter, OrderingFilter | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework_simplejwt.authentication import JWTAuthentication | ||
from django_filters.rest_framework import DjangoFilterBackend | ||
|
||
|
||
from student_welfare_backend.core.models import FAQ | ||
from student_welfare_backend.core.api.serializers import FAQSerializer | ||
from student_welfare_backend.customs.pagination import CustomPagination | ||
from student_welfare_backend.customs.permissions import IsDSW, IsADSW | ||
|
||
|
||
class FAQViewSet(ReadOnlyModelViewSet): | ||
authentication_classes = [] | ||
permission_classes = [] | ||
queryset = FAQ.objects.all() | ||
serializer_class = FAQSerializer | ||
pagination_class = CustomPagination | ||
filter_backends = [SearchFilter, OrderingFilter, DjangoFilterBackend] | ||
search_fields = ["question", "answer"] | ||
ordering_fields = ["question"] | ||
ordering = ["question"] | ||
|
||
|
||
class FAQAdminViewSet(ModelViewSet): | ||
authentication_classes = [JWTAuthentication] | ||
permission_classes = [IsAuthenticated, IsDSW | IsADSW] | ||
queryset = FAQ.objects.all() | ||
serializer_class = FAQSerializer | ||
pagination_class = CustomPagination | ||
filter_backends = [SearchFilter, OrderingFilter, DjangoFilterBackend] | ||
search_fields = ["question", "answer"] | ||
ordering_fields = ["question"] | ||
ordering = ["question"] |
37 changes: 37 additions & 0 deletions
37
student_welfare_backend/student_welfare_backend/core/api/views/special_files.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet | ||
from rest_framework.filters import SearchFilter, OrderingFilter | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework_simplejwt.authentication import JWTAuthentication | ||
from django_filters.rest_framework import DjangoFilterBackend | ||
|
||
|
||
from student_welfare_backend.core.models import SpecialFile | ||
from student_welfare_backend.core.api.serializers import SpecialFileSerializer | ||
from student_welfare_backend.customs.pagination import CustomPagination | ||
from student_welfare_backend.customs.permissions import IsDSW, IsADSW | ||
|
||
|
||
class SpecialFileViewSet(ReadOnlyModelViewSet): | ||
authentication_classes = [] | ||
permission_classes = [] | ||
queryset = SpecialFile.objects.all() | ||
serializer_class = SpecialFileSerializer | ||
pagination_class = CustomPagination | ||
filter_backends = [SearchFilter, OrderingFilter, DjangoFilterBackend] | ||
filterset_fields = ["type"] | ||
search_fields = ["year", "type"] | ||
ordering_fields = ["year"] | ||
ordering = ["-year"] | ||
|
||
|
||
class SpecialFileAdminViewSet(ModelViewSet): | ||
authentication_classes = [JWTAuthentication] | ||
permission_classes = [IsAuthenticated, IsDSW | IsADSW] | ||
queryset = SpecialFile.objects.all() | ||
serializer_class = SpecialFileSerializer | ||
pagination_class = CustomPagination | ||
filter_backends = [SearchFilter, OrderingFilter, DjangoFilterBackend] | ||
filterset_fields = ["type"] | ||
search_fields = ["year", "type"] | ||
ordering_fields = ["year"] | ||
ordering = ["-year"] |
44 changes: 44 additions & 0 deletions
44
...e_backend/student_welfare_backend/core/migrations/0012_faq_specialfile_alter_club_type.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 4.0.10 on 2024-03-17 12:50 | ||
|
||
import django.core.validators | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('core', '0011_newsletter'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='FAQ', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('question', models.CharField(max_length=255)), | ||
('answer', models.TextField()), | ||
], | ||
options={ | ||
'verbose_name': 'FAQ', | ||
'verbose_name_plural': 'FAQs', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='SpecialFile', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('year', models.CharField(max_length=4, validators=[django.core.validators.RegexValidator(message='Year must be 4 digits long', regex='^\\d{4}$')])), | ||
('type', models.CharField(choices=[('events', 'Events'), ('program_representatives', 'Program Representatives')], max_length=100)), | ||
('file_link', models.CharField(max_length=255)), | ||
], | ||
options={ | ||
'verbose_name': 'Special File', | ||
'verbose_name_plural': 'Special Files', | ||
}, | ||
), | ||
migrations.AlterField( | ||
model_name='club', | ||
name='type', | ||
field=models.CharField(choices=[('student_welfare', 'Student Welfare'), ('student_council', 'Student Council'), ('club', 'Club'), ('chapter', 'Chapter'), ('team', 'Team'), ('greviance_cell', 'Greviance Cell'), ('counseling_division', 'Counseling Division'), ('other', 'Other')], default='club', max_length=50, verbose_name='Type'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters