-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from hackupc/checkin-admin
Add checkin admin interface. solves #74
- Loading branch information
Showing
6 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
from checkin import models | ||
from django.contrib import admin | ||
|
||
|
||
# Register your models here. | ||
|
||
class CheckinAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
'user', 'application', 'update_time' | ||
) | ||
search_fields = list_display | ||
date_hierarchy = 'update_time' | ||
|
||
admin.site.register(models.CheckIn, admin_class=CheckinAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.10.4 on 2017-02-26 03:52 | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('register', '0007_permissions'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CheckIn', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('update_time', models.DateTimeField()), | ||
('application', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='register.Application')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,23 @@ | ||
from __future__ import unicode_literals | ||
|
||
from django.contrib.auth import models as admin_models | ||
from django.db import models | ||
from register.models import Application | ||
|
||
# Create your models here. | ||
from django.utils.datetime_safe import datetime | ||
from register.models import APP_CONFIRMED | ||
|
||
|
||
class CheckIn(models.Model): | ||
application = models.OneToOneField('register.Application') | ||
application = models.ForeignKey('register.Application') | ||
user = models.ForeignKey(admin_models.User) | ||
update_time = models.DateTimeField() | ||
|
||
def save(self, force_insert=False, force_update=False, using=None, | ||
update_fields=None): | ||
self.update_time = datetime.now() | ||
super(CheckIn, self).save(force_insert, force_update, using, update_fields) | ||
|
||
def delete(self, using=None, keep_parents=False): | ||
self.application.status = APP_CONFIRMED | ||
self.application.save() | ||
super(CheckIn, self).delete(using, keep_parents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters