Begin ad CRUD
This commit is contained in:
parent
fa7ea66c65
commit
de559f8c40
|
@ -0,0 +1,48 @@
|
||||||
|
# Generated by Django 4.1.7 on 2023-03-10 00:41
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0008_platform'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Asset',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('code', models.CharField(max_length=64)),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Provider',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('code', models.CharField(max_length=64)),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Ad',
|
||||||
|
fields=[
|
||||||
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
('text', models.TextField()),
|
||||||
|
('payment_details', models.TextField()),
|
||||||
|
('payment_details_real', models.TextField()),
|
||||||
|
('payment_method_details', models.CharField(max_length=255)),
|
||||||
|
('dist_list', models.TextField()),
|
||||||
|
('asset_list', models.ManyToManyField(to='core.asset')),
|
||||||
|
('provider_list', models.ManyToManyField(to='core.provider')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -133,3 +133,55 @@ class Platform(models.Model):
|
||||||
@property
|
@property
|
||||||
def account_info(self):
|
def account_info(self):
|
||||||
return Aggregator.get_account_info_for_platform(self)
|
return Aggregator.get_account_info_for_platform(self)
|
||||||
|
|
||||||
|
|
||||||
|
class Asset(models.Model):
|
||||||
|
code = models.CharField(max_length=64)
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
|
||||||
|
class Provider(models.Model):
|
||||||
|
code = models.CharField(max_length=64)
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
|
||||||
|
class Ad(models.Model):
|
||||||
|
"""
|
||||||
|
An advert definition
|
||||||
|
"""
|
||||||
|
|
||||||
|
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
text = models.TextField()
|
||||||
|
|
||||||
|
# Shown when the user opens a trade
|
||||||
|
payment_details = models.TextField()
|
||||||
|
|
||||||
|
# Shown after
|
||||||
|
payment_details_real = models.TextField()
|
||||||
|
|
||||||
|
payment_method_details = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
dist_list = models.TextField()
|
||||||
|
|
||||||
|
asset_list = models.ManyToManyField(Asset)
|
||||||
|
provider_list = models.ManyToManyField(Provider)
|
||||||
|
|
||||||
|
|
||||||
|
# assets = {
|
||||||
|
# "XMR": "Monero",
|
||||||
|
# "BTC": "Bitcoin",
|
||||||
|
# }
|
||||||
|
# providers = {
|
||||||
|
# "REVOLUT": "Revolut",
|
||||||
|
# "NATIONAL_BANK": "Bank transfer",
|
||||||
|
# }
|
||||||
|
# for code, name in assets.items():
|
||||||
|
# if not Asset.objects.filter(code=code).exists():
|
||||||
|
# Asset.objects.create(code=code, name=name)
|
||||||
|
|
||||||
|
# for code, name in providers.items():
|
||||||
|
# if not Provider.objects.filter(code=code).exists():
|
||||||
|
# Provider.objects.create(code=code, name=name)
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.http import HttpResponse
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.views import View
|
||||||
|
from mixins.views import (
|
||||||
|
ObjectCreate,
|
||||||
|
ObjectDelete,
|
||||||
|
ObjectList,
|
||||||
|
ObjectRead,
|
||||||
|
ObjectUpdate,
|
||||||
|
)
|
||||||
|
from two_factor.views.mixins import OTPRequiredMixin
|
||||||
|
|
||||||
|
from core.clients.platforms.agora import AgoraClient
|
||||||
|
from core.forms import AdForm
|
||||||
|
from core.models import Ad
|
||||||
|
from core.util import logs
|
||||||
|
from core.views.helpers import synchronize_async_helper
|
||||||
|
|
||||||
|
|
||||||
|
class AdList(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||||||
|
list_template = "partials/ad-list.html"
|
||||||
|
model = Ad
|
||||||
|
page_title = "List of ad connections"
|
||||||
|
|
||||||
|
list_url_name = "ads"
|
||||||
|
list_url_args = ["type"]
|
||||||
|
|
||||||
|
submit_url_name = "ad_create"
|
||||||
|
|
||||||
|
|
||||||
|
class AdCreate(LoginRequiredMixin, OTPRequiredMixin, ObjectCreate):
|
||||||
|
model = Ad
|
||||||
|
form_class = AdForm
|
||||||
|
|
||||||
|
submit_url_name = "ad_create"
|
||||||
|
|
||||||
|
|
||||||
|
class AdUpdate(LoginRequiredMixin, OTPRequiredMixin, ObjectUpdate):
|
||||||
|
model = Ad
|
||||||
|
form_class = AdForm
|
||||||
|
|
||||||
|
submit_url_name = "ad_update"
|
||||||
|
|
||||||
|
|
||||||
|
class AdDelete(LoginRequiredMixin, OTPRequiredMixin, ObjectDelete):
|
||||||
|
model = Ad
|
Loading…
Reference in New Issue