Skip to content

Commit b620bb0

Browse files
committed
updated date field
1 parent 71f8ccf commit b620bb0

File tree

5 files changed

+117
-49
lines changed

5 files changed

+117
-49
lines changed

backend/fees_erp/views.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from django.shortcuts import render, redirect, HttpResponse
1414
from django.http import JsonResponse
1515
from django.template import loader
16-
from rest_framework.authentication import BasicAuthentication
16+
from rest_framework.authentication import BasicAuthentication, SessionAuthentication
1717

1818
from django.views.decorators.csrf import csrf_exempt
1919

@@ -309,29 +309,29 @@ def get(self, request):
309309
class feesAdminPanel(viewsets.ModelViewSet):
310310
queryset=Fees.objects.all()
311311
serializer_class=FeesSerializer
312-
permission_classes = [IsAccount]
313-
# authentication_classes =[BasicAuthentication] # only for testing remove when in production
312+
permission_classes = [IsAuthenticated,IsAccount]
313+
authentication_classes =[BasicAuthentication] # only for testing remove when in production
314314

315315
class studentFeesAdminPanel(viewsets.ModelViewSet):
316316
queryset=StudentFees.objects.all()
317317
serializer_class=StudentFeesSerializer
318-
permission_classes = [IsAccount]
319-
# authentication_classes =[BasicAuthentication] # only for testing remove when in production
318+
permission_classes = [IsAuthenticated,IsAccount]
319+
authentication_classes =[BasicAuthentication] # only for testing remove when in production
320320

321321
class splitpayment(viewsets.ModelViewSet):
322322
queryset=SplitPayment.objects.all()
323323
serializer_class=SplitPaymentSerializer
324-
permission_classes = [IsAccount]
325-
# authentication_classes =[BasicAuthentication] # only for testing remove when in production
324+
permission_classes = [IsAuthenticated,IsAccount]
325+
authentication_classes =[BasicAuthentication] # only for testing remove when in production
326326

327327
class BilldeskOrdersFunc(viewsets.ReadOnlyModelViewSet):
328328
queryset=BilldeskOrders.objects.all()
329329
serializer_class=billdeskorderSerializer
330-
permission_classes = [IsAccount]
331-
# authentication_classes =[BasicAuthentication] # only for testing remove when in production
330+
permission_classes = [IsAuthenticated,IsAccount]
331+
authentication_classes =[BasicAuthentication] # only for testing remove when in production
332332

333333
class BilldeskTransactionsFunc(viewsets.ReadOnlyModelViewSet):
334334
queryset=BilldeskTransactions.objects.all()
335335
serializer_class=billdesktransactionSerializer
336-
permission_classes = [IsAccount]
337-
# authentication_classes =[BasicAuthentication] # only for testing remove when in production
336+
permission_classes = [IsAuthenticated,IsAccount]
337+
authentication_classes =[BasicAuthentication] # only for testing remove when in production
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 4.2.6 on 2024-05-06 22:24
2+
3+
from django.db import migrations, models
4+
import placement.models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('placement', '0008_placements_archive'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='announcement',
16+
name='date',
17+
field=models.DateField(default=placement.models.get_current_date),
18+
),
19+
migrations.AlterField(
20+
model_name='placements',
21+
name='date',
22+
field=models.DateField(default=placement.models.get_current_date),
23+
),
24+
]

backend/placement/models.py

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,53 @@
55

66

77

8+
# class Placements(models.Model):
9+
# company_name = models.CharField(max_length= 40)
10+
# pkg_offered = models.FloatField()
11+
# role = models.CharField(max_length= 20)
12+
# docs = models.FileField(upload_to='assets/' , null=True )
13+
# # date= models.DateTimeField(default= timezone.now)
14+
# date = models.DateField(default=timezone.now().date)
15+
# description = models.TextField()
16+
# archive = models.BooleanField(default=False)
17+
18+
19+
# def __str__(self) -> str:
20+
# return self.company_name
21+
22+
23+
# class Announcement(models.Model):
24+
# title = models.CharField(max_length= 20)
25+
# desc = models.TextField()
26+
# docs = models.FileField(upload_to='assets/' , null=True )
27+
# date = models.DateField(default=timezone.now().date)
28+
# archive = models.BooleanField(default=False)
29+
30+
# def __str__(self) -> str:
31+
# return self.title
32+
33+
def get_current_date():
34+
return timezone.now().date()
35+
836
class Placements(models.Model):
9-
company_name = models.CharField(max_length= 40)
37+
company_name = models.CharField(max_length=40)
1038
pkg_offered = models.FloatField()
11-
role = models.CharField(max_length= 20)
12-
docs = models.FileField(upload_to='assets/' , null=True )
13-
date= models.DateTimeField(default= timezone.now)
39+
role = models.CharField(max_length=20)
40+
docs = models.FileField(upload_to='assets/', null=True)
41+
date = models.DateField(default=get_current_date)
1442
description = models.TextField()
1543
archive = models.BooleanField(default=False)
1644

17-
18-
def __str__(self) -> str:
45+
def __str__(self):
1946
return self.company_name
2047

2148

2249
class Announcement(models.Model):
23-
title = models.CharField(max_length= 20)
50+
title = models.CharField(max_length=20)
2451
desc = models.TextField()
25-
docs = models.FileField(upload_to='assets/' , null=True )
26-
date = models.DateTimeField(default= timezone.now)
52+
docs = models.FileField(upload_to='assets/', null=True)
53+
date = models.DateField(default=get_current_date)
2754
archive = models.BooleanField(default=False)
2855

29-
def __str__(self) -> str:
30-
return self.title
56+
def __str__(self):
57+
return self.title

backend/placement/serializers.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
1+
# from rest_framework import serializers
2+
# from .models import Placements, Announcement
3+
4+
# class PlacementSerializer(serializers.ModelSerializer):
5+
# class Meta:
6+
# model = Placements
7+
# fields = '__all__'
8+
9+
# # class PastPlacementSerializer(serializers.ModelSerializer):
10+
# # class Meta:
11+
# # model = PastPlacements
12+
# # fields = '__all__'
13+
14+
# # class ActivePlacementSerializer(serializers.ModelSerializer):
15+
# # class Meta:
16+
# # model = ActivePlacements
17+
# # fields = '__all__'
18+
19+
# class AnnouncementSerializer(serializers.ModelSerializer):
20+
# class Meta:
21+
# model = Announcement
22+
# fields = '__all__'
23+
24+
# # class PlacementOfficerSerializer(serializers.ModelSerializer):
25+
# # model = Announcement
26+
# # fields = '__all__'
127
from rest_framework import serializers
228
from .models import Placements, Announcement
29+
from .models import get_current_date
330

431
class PlacementSerializer(serializers.ModelSerializer):
32+
date = serializers.DateField(default=get_current_date) # Use get_current_date function
33+
534
class Meta:
635
model = Placements
736
fields = '__all__'
837

9-
# class PastPlacementSerializer(serializers.ModelSerializer):
10-
# class Meta:
11-
# model = PastPlacements
12-
# fields = '__all__'
13-
14-
# class ActivePlacementSerializer(serializers.ModelSerializer):
15-
# class Meta:
16-
# model = ActivePlacements
17-
# fields = '__all__'
18-
1938
class AnnouncementSerializer(serializers.ModelSerializer):
39+
date = serializers.DateField(default=get_current_date) # Use get_current_date function
40+
2041
class Meta:
2142
model = Announcement
2243
fields = '__all__'
23-
24-
# class PlacementOfficerSerializer(serializers.ModelSerializer):
25-
# model = Announcement
26-
# fields = '__all__'

backend/placement/views.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@
44
from .serializers import *
55
from rest_framework.viewsets import ModelViewSet
66
from rest_framework.permissions import IsAuthenticated
7-
# from rest_framework.authentication import SessionAuthentication
7+
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
88
from django.utils import timezone
99

1010

1111
# Create your views here.
1212

1313
class AllPlacementRecords(ModelViewSet):
14-
# authentication_classes =[SessionAuthentication]
15-
permission_classes =[ WriteByPlacement ]
16-
# authentication_classes =[BasicAuthentication]
17-
# permission_classes =[IsAuthenticated, WriteByPlacement ]
14+
authentication_classes =[SessionAuthentication]
15+
# permission_classes =[ WriteByPlacement ]
16+
authentication_classes =[BasicAuthentication]
17+
permission_classes =[IsAuthenticated, WriteByPlacement ]
1818
serializer_class = PlacementSerializer
1919
queryset = Placements.objects.all()
2020

2121
class ViewAnnouncement(ModelViewSet):
22-
# authentication_classes = [BasicAuthentication]
22+
authentication_classes = [BasicAuthentication]
2323
# authentication_classes =[SessionAuthentication]
24-
permission_classes = [WriteByPlacement]
25-
# permission_classes = [IsAuthenticated, WriteByPlacement]
24+
# permission_classes = [WriteByPlacement]
25+
permission_classes = [IsAuthenticated, WriteByPlacement]
2626
serializer_class = AnnouncementSerializer
2727
queryset = Announcement.objects.all()
2828

@@ -34,20 +34,20 @@ class ViewAnnouncement(ModelViewSet):
3434

3535

3636
class PastPlacementRecords(ModelViewSet):
37-
# authentication_classes = [BasicAuthentication]
37+
authentication_classes = [BasicAuthentication]
3838

3939
# authentication_classes =[SessionAuthentication]
4040
permission_classes = [WriteByPlacement]
41-
# permission_classes = [IsAuthenticated, WriteByPlacement]
41+
permission_classes = [IsAuthenticated, WriteByPlacement]
4242
serializer_class = PlacementSerializer
4343
queryset = Placements.objects.filter(date__lte=timezone.now())
4444

4545

4646

4747
class ActivePlacementRecords(ModelViewSet):
48-
# authentication_classes = [BasicAuthentication]
49-
permission_classes = [ WriteByPlacement]
48+
authentication_classes = [BasicAuthentication]
49+
# permission_classes = [ WriteByPlacement]
5050
# authentication_classes =[SessionAuthentication]
51-
# permission_classes = [IsAuthenticated, WriteByPlacement]
51+
permission_classes = [IsAuthenticated, WriteByPlacement]
5252
serializer_class = PlacementSerializer
5353
queryset = Placements.objects.filter(date__gt=timezone.now())

0 commit comments

Comments
 (0)