From 1f9a32e62e2996a318283d47e46595249ac7f0dc Mon Sep 17 00:00:00 2001 From: "Puliuvarthi.Mahesh" <134507390+MaheshPulivarthi18@users.noreply.github.com> Date: Tue, 19 Mar 2024 23:41:53 +0530 Subject: [PATCH 1/2] club budget updates --- .../migrations/0002_auto_20240302_1616.py | 18 +++++ .../migrations/0003_auto_20240302_1621.py | 18 +++++ FusionIIIT/applications/gymkhana/views.py | 73 ++++++++++++++++--- .../research_procedures/models.py | 2 +- .../gymkhanaModule/approvalrequests.html | 45 +++++++++--- .../templates/gymkhanaModule/clubbudget.html | 6 +- 6 files changed, 136 insertions(+), 26 deletions(-) create mode 100644 FusionIIIT/applications/globals/migrations/0002_auto_20240302_1616.py create mode 100644 FusionIIIT/applications/globals/migrations/0003_auto_20240302_1621.py diff --git a/FusionIIIT/applications/globals/migrations/0002_auto_20240302_1616.py b/FusionIIIT/applications/globals/migrations/0002_auto_20240302_1616.py new file mode 100644 index 000000000..814fa9ac7 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0002_auto_20240302_1616.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-03-02 16:16 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='extrainfo', + name='user_status', + field=models.CharField(choices=[('NEW', 'NEW'), ('PRESENT', 'PRESENT')], default='PRESENT', max_length=50), + ), + ] diff --git a/FusionIIIT/applications/globals/migrations/0003_auto_20240302_1621.py b/FusionIIIT/applications/globals/migrations/0003_auto_20240302_1621.py new file mode 100644 index 000000000..cdcaa9cf1 --- /dev/null +++ b/FusionIIIT/applications/globals/migrations/0003_auto_20240302_1621.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2024-03-02 16:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('globals', '0002_auto_20240302_1616'), + ] + + operations = [ + migrations.AlterField( + model_name='extrainfo', + name='user_status', + field=models.CharField(choices=[('PRESENT', 'PRESENT'), ('NEW', 'NEW')], default='PRESENT', max_length=50), + ), + ] diff --git a/FusionIIIT/applications/gymkhana/views.py b/FusionIIIT/applications/gymkhana/views.py index ddffa42f6..314a99c16 100644 --- a/FusionIIIT/applications/gymkhana/views.py +++ b/FusionIIIT/applications/gymkhana/views.py @@ -945,8 +945,8 @@ def club_budget(request): budget_file.name = club+"_budget" club_name = get_object_or_404(Club_info, club_name=club) - club_budget = Club_budget(club=club_name, budget_amt=budget_amount, - budget_file=budget_file, budget_for=budget_for, description=description) + club_budget = Club_budget(club_id=club_name, budget_amt=budget_amount, + budget_file=budget_file, budget_for=budget_for, description=description,status="open") club_budget.save() messages.success(request, "Successfully requested for the budget !!!") @@ -1623,7 +1623,7 @@ def vote(request,poll_id): @login_required def delete_poll(request, poll_id): - """ + """ delete_poll: This view delete the particular voting poll which is passed through function and redirect to "/gymkhana/" if there is an exception then it return the HttpResponse of "error" @@ -1633,17 +1633,68 @@ def delete_poll(request, poll_id): @variables: poll : It is an object stores the all data of poll_id from Voting_poll """ - try: - poll = Voting_polls.objects.filter(pk=poll_id) - poll.delete() - return redirect('/gymkhana/') - except Exception as e: - logger.info(e) - return HttpResponse('error') + try: + poll = Voting_polls.objects.filter(pk=poll_id) + poll.delete() + return redirect('/gymkhana/') + except Exception as e: + logger.info(e) + return HttpResponse('error') + + return redirect('/gymkhana/') - return redirect('/gymkhana/') # this algorithm checks if the passed slot time coflicts with any of already booked events +@login_required +def budget_approve(request): + """ + This view is used by the administration to approve the clubs_budget. + It gets a list of clubs and then approves_budget if they want to. + + @variables: + club_approve_list - list of clubs which has to be approved + club_name - gets the object and then confirms the club + """ + if request.method == "POST": + budget_approve_list = request.POST.getlist("check") + for club_id in budget_approve_list: + club_budget = get_object_or_404( + Club_budget, club_id=club_id, status="open" + ) # Ensure status is open + club_budget.status = "confirmed" + club_budget.save() # Save the changes + club_info = get_object_or_404(Club_info, club_id=club_id) + club_info.avail_budget += club_budget.budget_amt # Add the budget amount + club_info.save() # Save the changes + messages.success( + request, f"Successfully budget approved for {club_budget.club_id} club." + ) + return redirect("/gymkhana/") + + +@login_required +def budget_reject(request): + """ + This view is used by the administration to reject the clubs. + It gets a list of clubs and then rejects if they want to. + + @variables: + club_reject_list - list of clubs which has to be checked and rejected + club_name - gets the object and then rejects the club + + """ + if request.method == "POST": + budget_approve_list = request.POST.getlist("check") + for club in budget_approve_list: + club_budget = get_object_or_404(Club_budget, club_name=club) + club_budget.status = "rejected" + club_budget.save() + messages.success( + request, f"Successfully budget rejection for {club_budget.club_name} club." + ) + + return redirect("/gymkhana/") + def conflict_algorithm_event(date, start_time, end_time, venue): """ diff --git a/FusionIIIT/applications/research_procedures/models.py b/FusionIIIT/applications/research_procedures/models.py index 559b56fd9..6cf2b67aa 100644 --- a/FusionIIIT/applications/research_procedures/models.py +++ b/FusionIIIT/applications/research_procedures/models.py @@ -103,4 +103,4 @@ class TechTransfer(models.Model): end_date = models.DateField(null=True,blank=True) def __str__(self): - return 'PF No.: {} Details: {}'.format(self.pf_no, self.details) \ No newline at end of file + return 'PF No.: {} Details: {}'.format(self.pf_no, self.details) diff --git a/FusionIIIT/templates/gymkhanaModule/approvalrequests.html b/FusionIIIT/templates/gymkhanaModule/approvalrequests.html index de93af23a..8ff87896e 100644 --- a/FusionIIIT/templates/gymkhanaModule/approvalrequests.html +++ b/FusionIIIT/templates/gymkhanaModule/approvalrequests.html @@ -3,10 +3,9 @@ {% comment %}The tab menu starts here!{% endcomment %}