Skip to content

Commit

Permalink
Merge pull request #1605 from Harshul-25/latest_staging
Browse files Browse the repository at this point in the history
fixed bugs and api changes
  • Loading branch information
prabhatsuman authored May 5, 2024
2 parents 6167924 + 8912494 commit 14550e5
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 4 deletions.
4 changes: 4 additions & 0 deletions FusionIIIT/applications/central_mess/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@ class Meta:
class DeregistrationRequestSerializer(serializers.ModelSerializer):
class Meta:
model = Deregistration_Request
fields = ('__all__')
class UpdatePaymentRequestSerializer(serializers.ModelSerializer):
class Meta:
model = Update_Payment
fields = ('__all__')
2 changes: 2 additions & 0 deletions FusionIIIT/applications/central_mess/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@
url("get_student_all_details",views.Get_Student_Details.as_view(),name="get_student_details_API"),
url('registrationRequestApi', views.RegistrationRequestApi.as_view(), name='registrationRequestApi'),
url('deRegistrationRequestApi', views.DeregistrationRequestApi.as_view(), name='deRegistrationRequestApi'),
url('deRegistrationApi', views.DeregistrationApi.as_view(), name='deRegistrationApi'),
url('updatePaymentRequestApi', views.UpdatePaymentRequestApi.as_view(), name='updatePaymentRequestApi'),
]
73 changes: 73 additions & 0 deletions FusionIIIT/applications/central_mess/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ def put(self, request):
reg_main = Reg_main.objects.get(student_id=student)
reg_main.current_mess_status = "Registered"
reg_main.balance = F('balance') + amount
reg_main.mess_option = mess_option
except Reg_main.DoesNotExist:
reg_main = Reg_main.objects.create(
student_id=student,
Expand Down Expand Up @@ -717,6 +718,78 @@ def put(self, request):
reg_record.end_date = end_date
reg_record.save()
return Response({'status': 200})
except Exception as e:
print({'error': str(e)})
return Response({'error': str(e)}, status=400)

class DeregistrationApi(APIView):
def post(self, request):
try:
data = request.data
print(data)
student_id = data['student_id']
end_date = data['end_date']

username = get_object_or_404(User, username=student_id)
idd = ExtraInfo.objects.get(user=username)
student = Student.objects.get(id=idd.id)

reg_main = Reg_main.objects.get(student_id=student)
reg_main.current_mess_status = "Deregistered"
reg_main.save()

reg_record = Reg_records.objects.filter(student_id=student).latest('start_date')
reg_record.end_date = end_date
reg_record.save()
return Response({'status': 200})
except Exception as e:
print({'error': str(e)})
return Response({'error': str(e)}, status=400)

class UpdatePaymentRequestApi(APIView):
def get(self, request):
update_payment_requests = Update_Payment.objects.all()
serializer = UpdatePaymentRequestSerializer(update_payment_requests, many=True)
return Response({'status': 200, 'payload': serializer.data})

def post(self, request):
serializer = UpdatePaymentRequestSerializer(data=request.data)
if serializer.is_valid():
serializer.save()
return Response({'status': 200})
return Response(serializer.errors, status=400)

def put(self, request):
try:
data = request.data
print(data)
student_id = data['student_id']
payment_date = data['payment_date']
amount = data['amount']
Txn_no = data['Txn_no']
img = data['img']
new_status = data['status']
new_remark = data['update_payment_remark']

username = get_object_or_404(User, username=student_id)
idd = ExtraInfo.objects.get(user=username)
student = Student.objects.get(id=idd.id)

UpdatePayment_request = get_object_or_404(Update_Payment, student_id = student_id, payment_date = payment_date, amount = amount, Txn_no = Txn_no)

UpdatePayment_request.status = new_status
UpdatePayment_request.update_payment_remark = new_remark
UpdatePayment_request.save()

if (new_status == 'accept'):
new_payment_record = Payments(student_id = student, amount_paid = amount, payment_date=payment_date, payment_month=current_month(), payment_year=current_year())
new_payment_record.save()

reg_main = Reg_main.objects.get(student_id=student)
reg_main.balance = F('balance') + amount
reg_main.save()

return Response({'status': 200})
except Exception as e:
print({'error': str(e)})
return Response({'error': str(e)}, status=400)
4 changes: 2 additions & 2 deletions FusionIIIT/applications/central_mess/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class Payments(models.Model):
payment_year = models.IntegerField(default = current_year)
payment_date = models.DateField(default= datetime.date.today())

class Meta:
unique_together = (('student_id', 'payment_date'))
# class Meta:
# unique_together = (('student_id', 'payment_date'))

def __str__(self):
return '{}'.format(self.student_id.id)
Expand Down
2 changes: 1 addition & 1 deletion FusionIIIT/applications/central_mess/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def mess(request):
context = {
'menu': menu_data,
# 'reg_menu': y,
# 'messinfo': mess_optn,
'messinfo': mess_optn,
'monthly_bill': monthly_bill,
# 'total_due': amount_due,
'vaca': vaca_obj,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
</table>
</div>
</div>
<div class="ui active tab" data-tab="update-pay-req">
<div class="ui tab" data-tab="update-pay-req">
<div class="ui vertical strip segment" style="overflow-y:scroll;">

<table class="ui very basic collapsing celled table sortable centered" style="margin: auto;">
Expand Down

0 comments on commit 14550e5

Please sign in to comment.