Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Princekumarofficial committed Sep 3, 2024
1 parent 8bdef34 commit 9c7cd83
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 0 additions & 2 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,6 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
),
)

readonly_fields=("registration_time",)

def get_queryset(self, request):
qs = super().get_queryset(request)
if request.user.is_superuser:
Expand Down
5 changes: 3 additions & 2 deletions home/migrations/0004_allocation_registration_time.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by Django 5.0.8 on 2024-09-03 14:38
# Generated by Django 5.0.8 on 2024-09-03 16:13

import django.utils.timezone
from django.db import migrations, models


Expand All @@ -13,6 +14,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='allocation',
name='registration_time',
field=models.DateTimeField(auto_now_add=True, help_text='This contains the time of registration', null=True, verbose_name='Registration time'),
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, help_text='This contains the time of registration', null=True, verbose_name='Registration time'),
),
]
5 changes: 3 additions & 2 deletions home/models/allocation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from django.utils.translation import gettext as _
from django.utils.timezone import now

from .caterer import Caterer

Expand Down Expand Up @@ -122,10 +123,10 @@ class Allocation(models.Model):
)
registration_time = models.DateTimeField(
_("Registration time"),
auto_now_add=True,
default=now,
blank=True,
null=True,
help_text="This contains the time of registration",
help_text="This contains the date and time of registration",
editable=True,
)

Expand Down
7 changes: 7 additions & 0 deletions home/resources.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from import_export import fields, resources
from django.utils import timezone

from .models import (
Allocation,
Expand Down Expand Up @@ -78,6 +79,12 @@ class AllocationResource(resources.ModelResource):
attribute="second_pref", column_name="Second Preferences"
)
third_pref = fields.Field(attribute="third_pref", column_name="Third Preferences")
registration_time = fields.Field(attribute="registration_time", column_name="Registration Date Time")

def dehydrate_registration_time(self, allocation):
# Convert the registration_time to local time
local_time = timezone.localtime(allocation.registration_time)
return local_time.strftime('%Y-%m-%d %H:%M:%S')

class Meta:
model = Allocation
Expand Down
2 changes: 1 addition & 1 deletion messWebsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
SECRET_KEY = env("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ["diningfee.iiti.ac.in", "127.0.0.1"]
CSRF_TRUSTED_ORIGINS = ["http://diningfee.iiti.ac.in", "https://diningfee.iiti.ac.in"]
Expand Down

0 comments on commit 9c7cd83

Please sign in to comment.