diff --git a/FusionIIIT/applications/globals/migrations/0002_auto_20240115_1651.py b/FusionIIIT/applications/globals/migrations/0002_auto_20240115_1651.py deleted file mode 100644 index e7c68233d..000000000 --- a/FusionIIIT/applications/globals/migrations/0002_auto_20240115_1651.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-01-15 16:51 - -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_20240210_1752.py b/FusionIIIT/applications/globals/migrations/0003_auto_20240210_1752.py deleted file mode 100644 index 50441b81b..000000000 --- a/FusionIIIT/applications/globals/migrations/0003_auto_20240210_1752.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-10 17:52 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0002_auto_20240115_1651'), - ] - - 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/globals/migrations/0004_auto_20240212_1537.py b/FusionIIIT/applications/globals/migrations/0004_auto_20240212_1537.py deleted file mode 100644 index 0e5541cb3..000000000 --- a/FusionIIIT/applications/globals/migrations/0004_auto_20240212_1537.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-12 15:37 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0003_auto_20240210_1752'), - ] - - 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/0005_auto_20240212_2152.py b/FusionIIIT/applications/globals/migrations/0005_auto_20240212_2152.py deleted file mode 100644 index e5cb98c49..000000000 --- a/FusionIIIT/applications/globals/migrations/0005_auto_20240212_2152.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-12 21:52 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0004_auto_20240212_1537'), - ] - - 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/globals/migrations/0006_auto_20240212_2215.py b/FusionIIIT/applications/globals/migrations/0006_auto_20240212_2215.py deleted file mode 100644 index ab252a31d..000000000 --- a/FusionIIIT/applications/globals/migrations/0006_auto_20240212_2215.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-12 22:15 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0005_auto_20240212_2152'), - ] - - 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/0007_auto_20240213_0036.py b/FusionIIIT/applications/globals/migrations/0007_auto_20240213_0036.py deleted file mode 100644 index f5984571a..000000000 --- a/FusionIIIT/applications/globals/migrations/0007_auto_20240213_0036.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-13 00:36 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0006_auto_20240212_2215'), - ] - - 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/globals/migrations/0008_auto_20240213_1739.py b/FusionIIIT/applications/globals/migrations/0008_auto_20240213_1739.py deleted file mode 100644 index e710bc7c6..000000000 --- a/FusionIIIT/applications/globals/migrations/0008_auto_20240213_1739.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-13 17:39 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0007_auto_20240213_0036'), - ] - - 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/0009_auto_20240214_1648.py b/FusionIIIT/applications/globals/migrations/0009_auto_20240214_1648.py deleted file mode 100644 index f935078e8..000000000 --- a/FusionIIIT/applications/globals/migrations/0009_auto_20240214_1648.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-14 16:48 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0008_auto_20240213_1739'), - ] - - 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/globals/migrations/0010_auto_20240214_1808.py b/FusionIIIT/applications/globals/migrations/0010_auto_20240214_1808.py deleted file mode 100644 index 00b23336e..000000000 --- a/FusionIIIT/applications/globals/migrations/0010_auto_20240214_1808.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.1.5 on 2024-02-14 18:08 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - ('globals', '0009_auto_20240214_1648'), - ] - - operations = [ - migrations.AlterField( - model_name='extrainfo', - name='department', - field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='globals.departmentinfo'), - ), - ] diff --git a/FusionIIIT/applications/globals/models.py b/FusionIIIT/applications/globals/models.py index ba982a0e1..31eedcfb4 100644 --- a/FusionIIIT/applications/globals/models.py +++ b/FusionIIIT/applications/globals/models.py @@ -149,7 +149,7 @@ class ExtraInfo(models.Model): phone_no = models.BigIntegerField(null=True, default=9999999999) user_type = models.CharField(max_length=20, choices=Constants.USER_CHOICES) department = models.ForeignKey( - DepartmentInfo, on_delete=models.CASCADE, null=False, blank=True) + DepartmentInfo, on_delete=models.CASCADE, null=True, blank=True) profile_picture = models.ImageField( null=True, blank=True, upload_to='globals/profile_pictures') about_me = models.TextField(default='NA', max_length=1000, blank=True) diff --git a/FusionIIIT/applications/gymkhana/migrations/0003_auto_20240216_1824.py b/FusionIIIT/applications/gymkhana/migrations/0003_auto_20240216_1824.py new file mode 100644 index 000000000..ed9247870 --- /dev/null +++ b/FusionIIIT/applications/gymkhana/migrations/0003_auto_20240216_1824.py @@ -0,0 +1,24 @@ +# Generated by Django 3.1.5 on 2024-02-16 18:24 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('gymkhana', '0002_auto_20240214_1808'), + ] + + operations = [ + migrations.AlterField( + model_name='club_info', + name='created_on', + field=models.DateField(default=django.utils.timezone.now), + ), + migrations.AlterField( + model_name='club_info', + name='head_changed_on', + field=models.DateField(default=django.utils.timezone.now), + ), + ] diff --git a/FusionIIIT/applications/gymkhana/migrations/0004_auto_20240216_1907.py b/FusionIIIT/applications/gymkhana/migrations/0004_auto_20240216_1907.py new file mode 100644 index 000000000..61562cfa7 --- /dev/null +++ b/FusionIIIT/applications/gymkhana/migrations/0004_auto_20240216_1907.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.5 on 2024-02-16 19:07 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('gymkhana', '0003_auto_20240216_1824'), + ] + + operations = [ + migrations.AlterField( + model_name='club_info', + name='created_on', + field=models.DateField(default=None, null=True), + ), + migrations.AlterField( + model_name='club_info', + name='head_changed_on', + field=models.DateField(default=None, null=True), + ), + ] diff --git a/FusionIIIT/applications/gymkhana/migrations/0005_auto_20240216_1929.py b/FusionIIIT/applications/gymkhana/migrations/0005_auto_20240216_1929.py new file mode 100644 index 000000000..58c86dd7a --- /dev/null +++ b/FusionIIIT/applications/gymkhana/migrations/0005_auto_20240216_1929.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.5 on 2024-02-16 19:29 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('gymkhana', '0004_auto_20240216_1907'), + ] + + operations = [ + migrations.AlterField( + model_name='club_info', + name='created_on', + field=models.DateField(default=django.utils.timezone.now, null=True), + ), + ] diff --git a/FusionIIIT/applications/gymkhana/migrations/0006_auto_20240217_1530.py b/FusionIIIT/applications/gymkhana/migrations/0006_auto_20240217_1530.py new file mode 100644 index 000000000..94e6ecab3 --- /dev/null +++ b/FusionIIIT/applications/gymkhana/migrations/0006_auto_20240217_1530.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.5 on 2024-02-17 15:30 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('gymkhana', '0005_auto_20240216_1929'), + ] + + operations = [ + migrations.AlterField( + model_name='club_info', + name='head_changed_on', + field=models.DateField(default=django.utils.timezone.now, null=True), + ), + ] diff --git a/FusionIIIT/applications/gymkhana/models.py b/FusionIIIT/applications/gymkhana/models.py index caaf126bb..4fa64b432 100644 --- a/FusionIIIT/applications/gymkhana/models.py +++ b/FusionIIIT/applications/gymkhana/models.py @@ -66,7 +66,7 @@ class Club_info(models.Model): spent_budget - the amount spent by the club avail_budget - the amount available at the club status - status of club wheather it is confirmed or not - + """ club_name = models.CharField(max_length=50, null=False, primary_key=True) @@ -93,8 +93,8 @@ class Club_info(models.Model): spent_budget = models.IntegerField(null=True, default=0) avail_budget = models.IntegerField(null=True, default=0) status = models.CharField(max_length=50, choices=Constants.status, default="open") - head_changed_on = models.DateField(default=None, auto_now=False, null=False) - created_on = models.DateField(default=None, auto_now=False, null=False) + head_changed_on = models.DateField(default=timezone.now, auto_now=False, null=True) + created_on = models.DateField(default=timezone.now, auto_now=False, null=True) def __str__(self): return str(self.club_name) @@ -222,6 +222,7 @@ class Club_budget(models.Model): budget_file - it is file which contains complete details regarding the amount they want to spend descrion - description about the budget if any """ + id = models.AutoField(primary_key=True) club = models.ForeignKey( Club_info, on_delete=models.CASCADE, max_length=50, null=False @@ -254,6 +255,7 @@ class Session_info(models.Model): details - for which purpose they are taking the session status - wheather it is approved/rejected. """ + id = models.AutoField(primary_key=True) club = models.ForeignKey( Club_info, on_delete=models.CASCADE, max_length=50, null=True diff --git a/FusionIIIT/applications/gymkhana/templatetags/voters_tag.py b/FusionIIIT/applications/gymkhana/templatetags/voters_tag.py index 408e7b643..61e354a6f 100644 --- a/FusionIIIT/applications/gymkhana/templatetags/voters_tag.py +++ b/FusionIIIT/applications/gymkhana/templatetags/voters_tag.py @@ -1,27 +1,29 @@ from django import template import re + register = template.Library() toggel = False + ## A tag function to find whether to show the poll to the user or not @register.simple_tag def validate(user, groups): - - roll = user.username[:4] + roll = user.username[:3] branch = user.extrainfo.department.name print(groups) if roll in groups.keys(): - if groups[roll][0] == 'All': + if groups[roll][0] == "All": return True else: if branch in groups[roll]: - return True + return True else: - return False + return False else: return False - + + @register.simple_tag def result(): - return toggel \ No newline at end of file + return toggel diff --git a/FusionIIIT/applications/gymkhana/views.py b/FusionIIIT/applications/gymkhana/views.py index 4f38f06b4..25a3354d0 100644 --- a/FusionIIIT/applications/gymkhana/views.py +++ b/FusionIIIT/applications/gymkhana/views.py @@ -989,7 +989,7 @@ def act_calender(request): @login_required def club_report(request): - """ + """ This function is used to add the details of the club event along with a report. It adds the club event details to the database. And also uploads report file. @@ -1007,31 +1007,32 @@ def club_report(request): report - the club_report file on the event uploads by the user who adds data """ - if request.method == 'POST' and request.FILES['report']: - # getting form data - club = request.POST.get('club') - user = request.POST.get("s_inc") - event = request.POST.get("event") - d_d = request.POST.get("d_d") - date = request.POST.get("date") - time = request.POST.get("time") - report = request.FILES["report"] - report.name = club+"_"+event+"_report" - - # getting queryset class objects - USER = user.split(' - ') - user_name = get_object_or_404(User, username=USER[1]) - extra = get_object_or_404(ExtraInfo, id=USER[0], user=user_name) - - club_name = get_object_or_404(Club_info, club_name=club) - - # saving data to the database - club_report = Club_report(club=club_name, incharge=extra, event_name=event, + if request.method == 'POST' and request.FILES['report']: + # getting form data + club = request.POST.get('club') + user = request.POST.get("s_inc") + event = request.POST.get("event") + d_d = request.POST.get("d_d") + date = request.POST.get("date") + time = request.POST.get("time") + report = request.FILES["report"] + report.name = club+"_"+event+"_report" + + # getting queryset class objects + USER = user.split(' - ') + user_name = get_object_or_404(User, username=USER[1]) + extra = get_object_or_404(ExtraInfo, id=USER[0], user=user_name) + + club_name = get_object_or_404(Club_info, club_name=club) + + # saving data to the database + club_report = Club_report(club=club_name, incharge=extra, event_name=event, date=date+" "+time, event_details=report, description=d_d) - club_report.save() - messages.success(request, "Successfully updated the report !!!") + club_report.save() + messages.success(request, "Successfully updated the report !!!") + + return redirect('/gymkhana/') - return redirect('/gymkhana/') @login_required def change_head(request): @@ -1106,7 +1107,6 @@ def change_head(request): # Handle non-POST requests or redirect if needed # return redirect('/gymkhana/') - @login_required def new_session(request): """ @@ -1310,23 +1310,27 @@ def approve(request): @login_required def club_approve(request): - """ + """ This view is used by the administration to approve the clubs. - It gets a list of clubs and then approves if they want to. + It gets a list of clubs and then approves 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 + @variables: + club_approve_list - list of clubs which has to be approved + club_name - gets the object and then confirms the club - """ - club_approve_list = list(request.POST.getlist('check')) - for club in club_approve_list: - club_name = get_object_or_404(Club_info, club_name=club) - club_name.status = "confirmed" - club_name.save() - messages.success(request, "Successfully Approved !!!") + """ + if request.method == "POST": + club_approve_list = request.POST.getlist("check") + for club in club_approve_list: + club_name = get_object_or_404(Club_info, club_name=club) + club_name.status = "confirmed" + club_name.created_on = timezone.now() + club_name.save() + messages.success( + request, f"Successfully approved {club_name.club_name} club." + ) - return redirect('/gymkhana/') + return redirect("/gymkhana/") @login_required diff --git a/FusionIIIT/templates/gymkhanaModule/active_poll.html b/FusionIIIT/templates/gymkhanaModule/active_poll.html index d5bee5b50..26570f47b 100644 --- a/FusionIIIT/templates/gymkhanaModule/active_poll.html +++ b/FusionIIIT/templates/gymkhanaModule/active_poll.html @@ -1,8 +1,8 @@ {% block active_poll %}