Skip to content

Commit

Permalink
Remove few models (#67)
Browse files Browse the repository at this point in the history
* remove few models

* migrate and keep adding

* update

* nit: fix

---------

Co-authored-by: Ishaan Mittal <[email protected]>
  • Loading branch information
mittal-ishaan and ishaan-tf authored Aug 17, 2024
1 parent aa4daf0 commit e42035d
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 581 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
db.sqlite3
db1.sqlite3
__pycache__
migrations
venv
.venv
media
Expand Down
36 changes: 7 additions & 29 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
Update,
)

from .resources import ( # AllocationResource,; CatererBillsResource,
AllocationNewResource,
CatererBillsNewResource,
from .resources import (
AllocationResource,
CatererBillsResource,
LongRebateResource,
RebateBillsResource,
RebateResource,
Expand Down Expand Up @@ -924,7 +924,7 @@ def export_as_csv(self, request, queryset):
@admin.register(Allocation)
class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
list_per_page = 500
resource_class = AllocationNewResource
resource_class = AllocationResource
model = Allocation
search_fields = (
"email__name",
Expand Down Expand Up @@ -994,7 +994,7 @@ def export_as_csv(self, request, queryset):
"""
Export action available in the admin page
"""
resource = AllocationNewResource()
resource = AllocationResource()
dataset = resource.export(queryset)
response = HttpResponse(dataset.csv, content_type="text/csv")
response["Content-Disposition"] = 'attachment; filename="allocation.csv"'
Expand Down Expand Up @@ -1049,31 +1049,9 @@ class about_Admin(admin.ModelAdmin):
}


# @admin.register(CatererBillsSpring23)
# class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
# resource_class = CatererBillsResource
# model = CatererBillsSpring23
# fieldsets = ((None,caterer_bill_fields,),)
# list_display = ("__str__", "period1_bills", "period2_bills", "period3_bills", "period4_bills", "period5_bills", "period6_bills",)
# search_fields = ("caterer__name",)
# actions = ["export_as_csv"]

# def export_as_csv(self, request, queryset):
# """
# Export action available in the admin page
# """
# resource = CatererBillsResource()
# dataset = resource.export(queryset)
# response = HttpResponse(dataset.csv, content_type="text/csv")
# response["Content-Disposition"] = 'attachment; filename="caterer_bills.csv"'
# return response

# export_as_csv.short_description = "Export Caterer Bills details to CSV"


@admin.register(CatererBills)
class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
resource_class = CatererBillsNewResource
resource_class = CatererBillsResource
model = CatererBills
fieldsets = (
(
Expand Down Expand Up @@ -1110,7 +1088,7 @@ def export_as_csv(self, request, queryset):
"""
Export action available in the admin page
"""
resource = CatererBillsNewResource()
resource = CatererBillsResource()
dataset = resource.export(queryset)
response = HttpResponse(dataset.csv, content_type="text/csv")
response["Content-Disposition"] = 'attachment; filename="caterer_bills.csv"'
Expand Down
6 changes: 0 additions & 6 deletions home/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,3 @@ def signup(self, request, user):
user.last_name = self.cleaned_data["last_name"]
user.save()
return user


# class CustomSocialSignupForm(SocialSignupForm):
# def __init__(self, *args, **kwargs):
# super().__init__(*args, **kwargs)
# self.prevent_enumeration = False
125 changes: 125 additions & 0 deletions home/migrations/0002_remove_allocationautumn22_month_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Generated by Django 5.0.3 on 2024-08-17 14:53

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("home", "0001_initial"),
]

operations = [
migrations.RemoveField(
model_name="allocationautumn22",
name="month",
),
migrations.RemoveField(
model_name="allocationautumn22",
name="roll_no",
),
migrations.RemoveField(
model_name="allocationautumn23",
name="month",
),
migrations.RemoveField(
model_name="allocationautumn23",
name="roll_no",
),
migrations.RemoveField(
model_name="allocationspring23",
name="month",
),
migrations.RemoveField(
model_name="allocationspring23",
name="roll_no",
),
migrations.AlterField(
model_name="scan",
name="student_id",
field=models.ForeignKey(
default=0,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="home.student",
),
),
migrations.RemoveField(
model_name="catererbillsautumn22",
name="caterer",
),
migrations.RemoveField(
model_name="catererbillsautumn23",
name="caterer",
),
migrations.RemoveField(
model_name="catererbillsspring23",
name="caterer",
),
migrations.RemoveField(
model_name="rebateautumn23",
name="email",
),
migrations.AddField(
model_name="longrebate",
name="reason",
field=models.TextField(
blank=True,
choices=[
("", "Choose the reason"),
(
"Incomplete form. Please submit a new rebate application",
"Incomplete form",
),
(
"Signature of approving authority missing. Please submit a new rebate application",
"Signature missing",
),
(
"Attached file is not the rebate form. Please submit a new rebate application with correct attachment",
"Wrong attached document",
),
(
"There is a date mismatch between the one written in the form and the one in the attached form. Please submit a new rebate application",
"There is a date mismatch between the one written in the form and the one in the attached form",
),
],
default="",
),
),
migrations.AlterField(
model_name="rule",
name="sno",
field=models.AutoField(primary_key=True, serialize=False),
),
migrations.DeleteModel(
name="PeriodAutumn22",
),
migrations.DeleteModel(
name="AllocationAutumn22",
),
migrations.DeleteModel(
name="PeriodAutumn23",
),
migrations.DeleteModel(
name="AllocationAutumn23",
),
migrations.DeleteModel(
name="PeriodSpring23",
),
migrations.DeleteModel(
name="AllocationSpring23",
),
migrations.DeleteModel(
name="CatererBillsAutumn22",
),
migrations.DeleteModel(
name="CatererBillsAutumn23",
),
migrations.DeleteModel(
name="CatererBillsSpring23",
),
migrations.DeleteModel(
name="RebateAutumn23",
),
]
113 changes: 0 additions & 113 deletions home/models/Semesters/autumn22.py
Original file line number Diff line number Diff line change
@@ -1,100 +1,9 @@
from django.db import models
from django.utils.translation import gettext as _

from ..caterer import Caterer
from ..students import Student


class PeriodAutumn22(models.Model):
Sno = models.IntegerField(
_("Sno"), default=0, help_text="This contains the serial number of the Period"
)
start_date = models.DateField(
help_text="This contains the start date of this Period for this semester",
null=True,
blank=True,
)
end_date = models.DateField(
help_text="This contains the end date of this Period of this semester",
null=True,
blank=True,
)

def __str__(self):
return str(self.Sno)

class Meta:
verbose_name = "Period Details for Autumn 2022"
verbose_name_plural = "Period Details for Autumn 2022"


class AllocationAutumn22(models.Model):
"""
Stores the Allocation details
"""

roll_no = models.ForeignKey(
Student, default=0, on_delete=models.SET_NULL, null=True
)
student_id = models.CharField(
_("Allocation Id"),
default=None,
max_length=30,
help_text="This contains the Allocation Id",
null=True,
blank=True,
)
month = models.ForeignKey(
PeriodAutumn22, default=0, on_delete=models.SET_NULL, null=True
)
caterer_name = models.CharField(
_("Caterer Name"),
max_length=50,
help_text="The text in this text field contains the caterer name.",
default="",
null=True,
blank=True,
)
high_tea = models.BooleanField(
_("High Tea"),
help_text="This contains the info if high tea is taken or not",
default=False,
null=True,
blank=True,
)
first_pref = models.CharField(
_("First Preference"),
default=None,
max_length=10,
help_text="This contians the first preference caterer of the student",
null=True,
blank=True,
)
second_pref = models.CharField(
_("Second Preference"),
default=None,
max_length=10,
help_text="This contians the first preference caterer of the student",
null=True,
blank=True,
)
third_pref = models.CharField(
_("Third Preference"),
default=None,
max_length=10,
help_text="This contians the first preference caterer of the student",
null=True,
blank=True,
)

def __str__(self):
return self.student_id

class Meta:
verbose_name = "Allocation Details for Autumn 2022"
verbose_name_plural = "Allocation Details for Autumn 2022"


class RebateAutumn22(models.Model):
"""
Storing the Rebate Bills of the Students for the Autumn Semester
Expand Down Expand Up @@ -162,25 +71,3 @@ def __str__(self):
class Meta:
verbose_name = "Rebate Bill Autumn 2022"
verbose_name_plural = "Rebate Bills Autumn 2022"


class CatererBillsAutumn22(models.Model):
"""
Storing the Bills of the Caterers for the Autumn Semester
"""

caterer = models.ForeignKey(Caterer, on_delete=models.SET_NULL, null=True)

period1_bills = models.IntegerField(_("Period 1 Bill"), default=0, null=True)
period2_bills = models.IntegerField(_("Period 2 Bill"), default=0, null=True)
period3_bills = models.IntegerField(_("Period 3 Bill"), default=0, null=True)
period4_bills = models.IntegerField(_("Period 4 Bill"), default=0, null=True)
period5_bills = models.IntegerField(_("Period 5 Bill"), default=0, null=True)
period6_bills = models.IntegerField(_("Period 6 Bill"), default=0, null=True)

def __str__(self):
return str(self.caterer.pk)

class Meta:
verbose_name = "Caterer Bill Autumn 2022"
verbose_name_plural = "Caterer Bills Autumn 2022"
Loading

0 comments on commit e42035d

Please sign in to comment.