Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unwanted models #102

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 0 additions & 145 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
LongRebate,
Period,
Rebate,
RebateAutumn22,
RebateSpring23,
Rule,
Scan,
Semester,
Expand All @@ -42,7 +40,6 @@
AllocationResource,
CatererBillsResource,
LongRebateResource,
RebateBillsResource,
RebateResource,
StudentBillsResource,
StudentResource,
Expand Down Expand Up @@ -732,148 +729,6 @@ def send_mail(self, request, queryset):
}


@admin.register(RebateAutumn22)
class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
model = RebateAutumn22
resource_class = RebateBillsResource
search_fields = (
"email__email",
"email__hostel",
"email__department",
"email__degree",
"email__roll_no",
"email__name",
)
list_filter = ("email__hostel", "email__department", "email__degree")
list_display = ("__str__", "roll_number", "name", "hostel")
fieldsets = (
(
None,
rebate_fields,
),
)

@admin.display(description="roll number")
def roll_number(self, obj):
return obj.email.roll_no

@admin.display(description="name")
def name(self, obj):
return obj.email.name

@admin.display(description="hostel")
def hostel(self, obj):
return obj.email.hostel

@admin.display(description="room number")
def room_number(self, obj):
return obj.email.room_no

actions = ["export_as_csv"]

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

export_as_csv.short_description = "Export Rebate details to CSV"


@admin.register(RebateSpring23)
class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
resource_class = RebateBillsResource
model = RebateSpring23
search_fields = (
"email__email",
"email__hostel",
"email__department",
"email__degree",
"email__roll_no",
"email__name",
)
list_filter = ("email__hostel", "email__degree", "email__department")
list_display = ("__str__", "roll_number", "name", "hostel")
fieldsets = (
(
None,
rebate_fields,
),
)

@admin.display(description="roll number")
def roll_number(self, obj):
return obj.email.roll_no

@admin.display(description="name")
def name(self, obj):
return obj.email.name

@admin.display(description="hostel")
def hostel(self, obj):
return obj.email.hostel

@admin.display(description="room number")
def room_number(self, obj):
return obj.email.room_no

actions = ["export_as_csv", "clean"]

@admin.action(description="Clean Null period data")
def clean(self, request, queryset):
"""
Clean testing period data
"""
attributes_to_check = [
("period1_short", 0),
("period1_long", 0),
("period2_short", 0),
("period2_long", 0),
("period3_short", 0),
("period3_long", 0),
("period4_short", 0),
("period4_long", 0),
("period5_short", 0),
("period5_long", 0),
("period6_short", 0),
("period6_long", 0),
("period1_high_tea", True),
("period2_high_tea", True),
("period3_high_tea", True),
("period4_high_tea", True),
("period5_high_tea", True),
("period6_high_tea", True),
("period1_bill", 0),
("period2_bill", 0),
("period3_bill", 0),
("period4_bill", 0),
("period5_bill", 0),
("period6_bill", 0),
]

for obj in queryset:
for attr, default_value in attributes_to_check:
if getattr(obj, attr) is None:
setattr(obj, attr, default_value)
obj.save()

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

export_as_csv.short_description = "Export Rebate details to CSV"


@admin.register(StudentBills)
class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
resource_class = StudentBillsResource
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.8 on 2024-11-17 09:01

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('home', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='rebatespring23',
name='email',
),
migrations.DeleteModel(
name='RebateAutumn22',
),
migrations.DeleteModel(
name='RebateSpring23',
),
]
73 changes: 0 additions & 73 deletions home/models/Semesters/autumn22.py

This file was deleted.

61 changes: 0 additions & 61 deletions home/models/Semesters/spring23.py

This file was deleted.

6 changes: 0 additions & 6 deletions home/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
from .home import About, Carousel, Update
from .links import Form
from .rules import Rule, ShortRebate
from .Semesters.autumn22 import (
RebateAutumn22,
)
from .Semesters.spring23 import (
RebateSpring23,
)
from .students import (
AllocationForm,
LeftLongRebate,
Expand Down
Loading
Loading