Skip to content

Commit

Permalink
add default event log type
Browse files Browse the repository at this point in the history
  • Loading branch information
jabelone committed Oct 22, 2023
1 parent 055f9e6 commit aca884a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
36 changes: 36 additions & 0 deletions memberportal/profile/migrations/0015_alter_log_logtype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 3.2.20 on 2023-10-22 05:05

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("profile", "0014_auto_20231022_1450"),
]

operations = [
migrations.AlterField(
model_name="log",
name="logtype",
field=models.CharField(
choices=[
("generic", "Generic log entry"),
("usage", "Generic usage access"),
("stripe", "Stripe related event"),
("memberbucks", "Memberbucks related event"),
("spacebucks", "Spacebucks related event"),
("profile", "Member profile was edited or updated"),
("interlock", "Interlock device related event"),
("door", "Door device related event"),
("memberbucksdevice", "Memberbucks device related event"),
("email", "An email was sent or attempted to be sent"),
("admin", "An admin performed an action"),
("error", "An event or action caused an error"),
("xero", "Generic xero log entry"),
],
default="generic",
max_length=30,
verbose_name="Type of action/event",
),
),
]
11 changes: 9 additions & 2 deletions memberportal/profile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@

class Log(models.Model):
id = models.AutoField(primary_key=True)
logtype = models.CharField("Type of action/event", choices=LOG_TYPES, max_length=30)
logtype = models.CharField(
"Type of action/event", choices=LOG_TYPES, max_length=30, default="generic"
)
description = models.CharField("Description of action/event", max_length=500)
data = models.TextField("Extra data for debugging action/event")
date = models.DateTimeField(auto_now_add=True)
Expand Down Expand Up @@ -79,7 +81,12 @@ class EventLog(Log):


def log_event(
description, event_type, data="", door=None, interlock=None, memberbucks_device=None
description,
event_type="generic",
data="",
door=None,
interlock=None,
memberbucks_device=None,
):
EventLog(
description=description,
Expand Down

0 comments on commit aca884a

Please sign in to comment.