-
Notifications
You must be signed in to change notification settings - Fork 13
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 #29 from patroqueeet/cherijs_develop
Cherijs develop
- Loading branch information
Showing
10 changed files
with
319 additions
and
18 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,6 +1,104 @@ | ||
from django.contrib import admin | ||
from django_walletpass.models import Pass, Registration, Log | ||
from django.template import Context, Template | ||
from django.urls import reverse | ||
from django.utils.html import format_html | ||
|
||
admin.site.register(Pass) | ||
admin.site.register(Registration) | ||
admin.site.register(Log) | ||
from django_walletpass.models import Log, Pass, Registration | ||
|
||
|
||
@admin.register(Log) | ||
class LogAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"created_at", | ||
"status", | ||
"task_type", | ||
# "pass_type_identifier", | ||
# "serial_number", | ||
"pass_", | ||
# "web_service_url", | ||
"device_id", | ||
"msg", | ||
) | ||
list_filter = ("status", "task_type", "pass_type_identifier") | ||
search_fields = ( | ||
"pass_type_identifier", | ||
"serial_number", | ||
"device_id", | ||
"msg", | ||
"message", | ||
) | ||
readonly_fields = ("created_at", "pass_") | ||
raw_id_fields = ("pazz",) | ||
list_select_related = ("pazz",) | ||
|
||
def pass_(self, obj: Log): | ||
if obj.pazz_id: | ||
url = reverse( | ||
"admin:%s_%s_change" | ||
% (obj.pazz._meta.app_label, obj.pazz._meta.model_name), | ||
args=[obj.pazz_id], | ||
) | ||
return format_html( | ||
"<a href='{url}'>{title}</a>", | ||
url=url, | ||
title=obj.serial_number, | ||
) | ||
return obj.serial_number | ||
|
||
pass_.short_description = "Pass" | ||
|
||
|
||
@admin.register(Pass) | ||
class PassAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
"serial_number", | ||
"updated_at", | ||
"pass_type_identifier", | ||
"wallet_pass_", | ||
) | ||
search_fields = ( | ||
"serial_number", | ||
"pass_type_identifier", | ||
"authentication_token", | ||
"data", | ||
) | ||
list_filter = ("pass_type_identifier", "updated_at") | ||
date_hierarchy = "updated_at" | ||
readonly_fields = ("wallet_pass_", "updated_at") | ||
|
||
def wallet_pass_(self, obj: Pass): | ||
if obj.data: | ||
return format_html( | ||
Template( | ||
"{% load static %}<a href='{url}' alt='{title}'><img src='{% static 'admin/passbook_icon.svg' %}'/></a>" | ||
).render(Context({})), | ||
url=obj.data.url, | ||
title=obj.data.name, | ||
) | ||
return | ||
|
||
wallet_pass_.short_description = "Pass" | ||
|
||
|
||
@admin.register(Registration) | ||
class RegistrationAdmin(admin.ModelAdmin): | ||
list_display = ("device_library_identifier", "push_token", "pass_") | ||
search_fields = ("device_library_identifier", "push_token", "pazz__serial_number") | ||
raw_id_fields = ("pazz",) | ||
readonly_fields = ("pass_",) | ||
|
||
def pass_(self, obj: Registration): | ||
if obj.pazz_id: | ||
url = reverse( | ||
"admin:%s_%s_change" | ||
% (obj.pazz._meta.app_label, obj.pazz._meta.model_name), | ||
args=[obj.pazz_id], | ||
) | ||
return format_html( | ||
"<a href='{url}'>{title}</a>", | ||
url=url, | ||
title=obj.pazz.serial_number, | ||
) | ||
return | ||
|
||
pass_.short_description = "Pass" |
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
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,66 @@ | ||
# Generated by Django 3.2.14 on 2023-07-09 18:43 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import django_walletpass.storage | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_walletpass', '0008_alter_pass_data'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='log', | ||
name='created_at', | ||
field=models.DateTimeField(default=django.utils.timezone.now), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='device_id', | ||
field=models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='msg', | ||
field=models.TextField(blank=True, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='pass_type_identifier', | ||
field=models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='pazz', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='logs', to='django_walletpass.pass'), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='serial_number', | ||
field=models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='status', | ||
field=models.CharField(blank=True, max_length=100, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='task_type', | ||
field=models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='log', | ||
name='web_service_url', | ||
field=models.URLField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='pass', | ||
name='data', | ||
field=models.FileField(storage=django_walletpass.storage.WalletPassStorage(), upload_to='passes'), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
django_walletpass/migrations/0010_alter_registration_push_token.py
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,18 @@ | ||
# Generated by Django 3.2.14 on 2023-07-13 10:41 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('django_walletpass', '0009_auto_20230709_2143'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='registration', | ||
name='push_token', | ||
field=models.CharField(max_length=255), | ||
), | ||
] |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.