-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): adding models and admin for address lists (#612)
* feat(app): adding models and admin for address lists * manual csv import * feat(api): working csv import, moved to account * feat(api): added allowlists to customizaion weights * cleanup
- Loading branch information
1 parent
4dc618b
commit 8cc7faf
Showing
12 changed files
with
628 additions
and
413 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
58 changes: 58 additions & 0 deletions
58
api/account/migrations/0025_addresslist_addresslistmember.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,58 @@ | ||
# Generated by Django 4.2.6 on 2024-06-11 22:12 | ||
|
||
import account.models | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("account", "0024_customization_scorer_panel_text"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="AddressList", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("name", models.CharField(db_index=True, max_length=100, unique=True)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name="AddressListMember", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"address", | ||
account.models.EthAddressField(db_index=True, max_length=100), | ||
), | ||
( | ||
"list", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="addresses", | ||
to="account.addresslist", | ||
), | ||
), | ||
], | ||
options={ | ||
"unique_together": {("address", "list")}, | ||
}, | ||
), | ||
] |
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,20 @@ | ||
# Generated by Django 4.2.6 on 2024-06-11 22:13 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("account", "0025_addresslist_addresslistmember"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="customization", | ||
name="scorer", | ||
field=models.OneToOneField( | ||
on_delete=django.db.models.deletion.PROTECT, to="account.community" | ||
), | ||
), | ||
] |
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,44 @@ | ||
# Generated by Django 4.2.6 on 2024-06-11 22:35 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("account", "0026_alter_customization_scorer"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="AllowList", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("weight", models.FloatField(default=0.0)), | ||
( | ||
"address_list", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.PROTECT, | ||
related_name="allow_lists", | ||
to="account.addresslist", | ||
), | ||
), | ||
( | ||
"customization", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="allow_lists", | ||
to="account.customization", | ||
), | ||
), | ||
], | ||
), | ||
] |
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,17 @@ | ||
# Generated by Django 4.2.6 on 2024-06-12 15:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("account", "0027_allowlist"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="allowlist", | ||
name="weight", | ||
field=models.DecimalField(decimal_places=4, default=0.0, max_digits=7), | ||
), | ||
] |
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
14 changes: 14 additions & 0 deletions
14
api/account/templates/account/address_list_csv_import_form.html
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,14 @@ | ||
{% extends 'admin/base.html' %} | ||
|
||
{% block content %} | ||
<div> | ||
<form action="." method="POST" enctype="multipart/form-data"> | ||
{{ form.as_p }} | ||
{% csrf_token %} | ||
|
||
<button type="submit">Upload CSV</button> | ||
</form> | ||
</div> | ||
<br /> | ||
|
||
{% endblock %} |
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,11 @@ | ||
{% extends 'admin/change_list.html' %} | ||
|
||
{% block object-tools %} | ||
<a style="padding: 8px; margin: 20px; font-weight: bold; text-decoration: none; border-radius: 12px; background-color: blue; color: white;" | ||
href="import-csv/"> | ||
Import CSV 📁 | ||
</a> | ||
<br /> | ||
<br /> | ||
{{ block.super }} | ||
{% endblock %} |
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