membershipworks: Add Transaction model and admin
Retroactively adding to the initial migration as this table already existed, just wasn't represented in the Django app yet
This commit is contained in:
parent
017aea4b3e
commit
7f7c6484ea
@ -1,6 +1,6 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Member, Flag
|
||||
from .models import Member, Flag, Transaction
|
||||
|
||||
|
||||
class ReadOnlyAdmin(admin.ModelAdmin):
|
||||
@ -31,3 +31,10 @@ class FlagAdmin(ReadOnlyAdmin):
|
||||
list_filter = ["type"]
|
||||
show_facets = admin.ShowFacets.ALWAYS
|
||||
search_fields = ["name"]
|
||||
|
||||
|
||||
@admin.register(Transaction)
|
||||
class TransactionAdmin(ReadOnlyAdmin):
|
||||
list_display = ["timestamp", "member", "name", "type", "sum", "note"]
|
||||
list_filter = ["type"]
|
||||
show_facets = admin.ShowFacets.ALWAYS
|
||||
|
@ -280,4 +280,80 @@ class Migration(migrations.Migration):
|
||||
"managed": False,
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="Transaction",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("sid", models.CharField(blank=True, max_length=27, null=True)),
|
||||
("timestamp", models.DateTimeField()),
|
||||
("type", models.TextField(blank=True, null=True)),
|
||||
(
|
||||
"sum",
|
||||
models.DecimalField(
|
||||
blank=True, decimal_places=4, max_digits=13, null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"fee",
|
||||
models.DecimalField(
|
||||
blank=True, decimal_places=4, max_digits=13, null=True
|
||||
),
|
||||
),
|
||||
("event_id", models.TextField(blank=True, null=True)),
|
||||
("for_what", models.TextField(blank=True, db_column="For", null=True)),
|
||||
("items", models.TextField(blank=True, db_column="Items", null=True)),
|
||||
(
|
||||
"discount_code",
|
||||
models.TextField(blank=True, db_column="Discount Code", null=True),
|
||||
),
|
||||
("note", models.TextField(blank=True, db_column="Note", null=True)),
|
||||
("name", models.TextField(blank=True, db_column="Name", null=True)),
|
||||
(
|
||||
"contact_person",
|
||||
models.TextField(blank=True, db_column="Contact Person", null=True),
|
||||
),
|
||||
(
|
||||
"full_address",
|
||||
models.TextField(blank=True, db_column="Full Address", null=True),
|
||||
),
|
||||
("street", models.TextField(blank=True, db_column="Street", null=True)),
|
||||
("city", models.TextField(blank=True, db_column="City", null=True)),
|
||||
(
|
||||
"state_province",
|
||||
models.TextField(blank=True, db_column="State/Province", null=True),
|
||||
),
|
||||
(
|
||||
"postal_code",
|
||||
models.TextField(blank=True, db_column="Postal Code", null=True),
|
||||
),
|
||||
(
|
||||
"country",
|
||||
models.TextField(blank=True, db_column="Country", null=True),
|
||||
),
|
||||
("phone", models.TextField(blank=True, db_column="Phone", null=True)),
|
||||
("email", models.TextField(blank=True, db_column="Email", null=True)),
|
||||
(
|
||||
"member",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
db_column="uid",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
related_name="transactions",
|
||||
to="membershipworks.member",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"db_table": "transactions",
|
||||
},
|
||||
),
|
||||
]
|
||||
|
@ -208,3 +208,40 @@ class MemberFlag(models.Model):
|
||||
fields=["member", "flag_id"], name="unique_member_flag"
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class Transaction(models.Model):
|
||||
sid = models.CharField(max_length=27, null=True, blank=True)
|
||||
member = models.ForeignKey(
|
||||
Member,
|
||||
on_delete=models.PROTECT,
|
||||
db_column="uid",
|
||||
related_name="transactions",
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
timestamp = models.DateTimeField()
|
||||
type = models.TextField(null=True, blank=True)
|
||||
sum = models.DecimalField(max_digits=13, decimal_places=4, null=True, blank=True)
|
||||
fee = models.DecimalField(max_digits=13, decimal_places=4, null=True, blank=True)
|
||||
event_id = models.TextField(null=True, blank=True)
|
||||
for_what = models.TextField(db_column="For", null=True, blank=True)
|
||||
items = models.TextField(db_column="Items", null=True, blank=True)
|
||||
discount_code = models.TextField(db_column="Discount Code", null=True, blank=True)
|
||||
note = models.TextField(db_column="Note", null=True, blank=True)
|
||||
name = models.TextField(db_column="Name", null=True, blank=True)
|
||||
contact_person = models.TextField(db_column="Contact Person", null=True, blank=True)
|
||||
full_address = models.TextField(db_column="Full Address", null=True, blank=True)
|
||||
street = models.TextField(db_column="Street", null=True, blank=True)
|
||||
city = models.TextField(db_column="City", null=True, blank=True)
|
||||
state_province = models.TextField(db_column="State/Province", null=True, blank=True)
|
||||
postal_code = models.TextField(db_column="Postal Code", null=True, blank=True)
|
||||
country = models.TextField(db_column="Country", null=True, blank=True)
|
||||
phone = models.TextField(db_column="Phone", null=True, blank=True)
|
||||
email = models.TextField(db_column="Email", null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.type} [{self.member if self.member else self.name}] {self.timestamp}"
|
||||
|
||||
class Meta:
|
||||
db_table = "transactions"
|
||||
|
Loading…
Reference in New Issue
Block a user