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

Add registration time #78

Merged
merged 4 commits into from
Sep 6, 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
3 changes: 2 additions & 1 deletion home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
"email__degree",
"email__department",
)
list_display = ("student_id", "name", "email", "period", "caterer", "jain")
list_display = ("student_id", "name", "email", "period", "caterer", "jain", "registration_time",)
fieldsets = (
(
None,
Expand All @@ -957,6 +957,7 @@ class about_Admin(ImportExportModelAdmin, admin.ModelAdmin):
"first_pref",
"second_pref",
"third_pref",
"registration_time",
),
"description": "%s" % ALLOCATION_DESC_TEXT,
},
Expand Down
19 changes: 19 additions & 0 deletions home/migrations/0004_allocation_registration_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0.8 on 2024-09-03 16:13

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


class Migration(migrations.Migration):

dependencies = [
('home', '0003_allocationform_show_allocated'),
]

operations = [
migrations.AddField(
model_name='allocation',
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'),
),
]
9 changes: 9 additions & 0 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 @@ -120,6 +121,14 @@ class Allocation(models.Model):
null=True,
blank=True,
)
registration_time = models.DateTimeField(
_("Registration time"),
default=now,
blank=True,
null=True,
help_text="This contains the date and time of registration",
editable=True,
)

def __str__(self):
return self.student_id
Expand Down
9 changes: 9 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 All @@ -99,6 +106,7 @@ class Meta:
"first_pref",
"second_pref",
"third_pref",
"registration_time",
)

export_order = [
Expand All @@ -116,6 +124,7 @@ class Meta:
"first_pref",
"second_pref",
"third_pref",
"registration_time",
]


Expand Down
11 changes: 8 additions & 3 deletions messWebsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,30 @@
# Application definition

INSTALLED_APPS = [
# Django apps
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"django.contrib.admindocs",

# Third-party apps
"import_export",
"django_admin_logs",
"home.apps.HomeConfig",
"django.contrib.sites",
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.google",
"django.contrib.admindocs",
"cloudinary_storage",
"cloudinary",
"apscheduler",
"django_apscheduler",

# Local apps
"home.apps.HomeConfig",
]

MIDDLEWARE = [
Expand Down
Loading