start project
This commit is contained in:
0
stacking/__init__.py
Normal file
0
stacking/__init__.py
Normal file
BIN
stacking/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
stacking/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
stacking/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/admin.cpython-310.pyc
Normal file
BIN
stacking/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/admin.cpython-311.pyc
Normal file
BIN
stacking/__pycache__/admin.cpython-311.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/apps.cpython-310.pyc
Normal file
BIN
stacking/__pycache__/apps.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/apps.cpython-311.pyc
Normal file
BIN
stacking/__pycache__/apps.cpython-311.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/models.cpython-310.pyc
Normal file
BIN
stacking/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/models.cpython-311.pyc
Normal file
BIN
stacking/__pycache__/models.cpython-311.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/serializers.cpython-310.pyc
Normal file
BIN
stacking/__pycache__/serializers.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/serializers.cpython-311.pyc
Normal file
BIN
stacking/__pycache__/serializers.cpython-311.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/views.cpython-310.pyc
Normal file
BIN
stacking/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/__pycache__/views.cpython-311.pyc
Normal file
BIN
stacking/__pycache__/views.cpython-311.pyc
Normal file
Binary file not shown.
12
stacking/admin.py
Normal file
12
stacking/admin.py
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
from django.contrib import admin
|
||||
from .models import Stake, UserStake
|
||||
|
||||
admin.site.register(Stake)
|
||||
admin.site.register(UserStake)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
6
stacking/apps.py
Normal file
6
stacking/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class StackingConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'stacking'
|
35
stacking/migrations/0001_initial.py
Normal file
35
stacking/migrations/0001_initial.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 5.0.6 on 2024-08-26 11:46
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('users', '0001_initial'),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='UserStake',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('amount', models.DecimalField(decimal_places=4, max_digits=30, verbose_name='Сумма')),
|
||||
('percent', models.IntegerField(blank=True, null=True, verbose_name='Процент бонусов')),
|
||||
('is_active', models.BooleanField(default=True, verbose_name='Автивен')),
|
||||
('start_date', models.DateTimeField(auto_now=True, verbose_name='Время начала')),
|
||||
('duration', models.IntegerField(blank=True, null=True, verbose_name='Длительность в днях')),
|
||||
('balance', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.balance')),
|
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Пользовательский Stake',
|
||||
'verbose_name_plural': 'Пользовательские Stake',
|
||||
},
|
||||
),
|
||||
]
|
@@ -0,0 +1,40 @@
|
||||
# Generated by Django 5.0.6 on 2024-08-29 07:41
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stacking', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Stake',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('stake_type', models.CharField(choices=[('DAY1', '1 день'), ('WEEK1', '1 неделя'), ('WEEK2', '2 недели'), ('MONTH1', '1 месяц'), ('MONTH3', '3 месяца'), ('MONTH6', '6 месяцев'), ('YEAR1', '1 год')], default='DAY1', max_length=250, verbose_name='Тип')),
|
||||
('percent', models.IntegerField(blank=True, null=True, verbose_name='Процент бонусов')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Stake',
|
||||
'verbose_name_plural': 'Stake',
|
||||
},
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='userstake',
|
||||
name='duration',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='userstake',
|
||||
name='percent',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='userstake',
|
||||
name='stake',
|
||||
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='stacking.stake'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
0
stacking/migrations/__init__.py
Normal file
0
stacking/migrations/__init__.py
Normal file
BIN
stacking/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
BIN
stacking/migrations/__pycache__/0001_initial.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
BIN
stacking/migrations/__pycache__/0001_initial.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
stacking/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
stacking/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
stacking/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
BIN
stacking/migrations/__pycache__/__init__.cpython-311.pyc
Normal file
Binary file not shown.
50
stacking/models.py
Normal file
50
stacking/models.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils import timezone
|
||||
from django.conf import settings
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from users.models import Balance
|
||||
|
||||
class Stake(models.Model):
|
||||
class StakeEnum(models.TextChoices):
|
||||
DAY1 = 'DAY1', _('1 день')
|
||||
WEEK1 = 'WEEK1', _('1 неделя')
|
||||
WEEK2 = 'WEEK2', _('2 недели')
|
||||
MONTH1 = 'MONTH1', _('1 месяц')
|
||||
MONTH3 = 'MONTH3', _('3 месяца')
|
||||
MONTH6 = 'MONTH6', _('6 месяцев')
|
||||
YEAR1 = 'YEAR1', _('1 год')
|
||||
|
||||
|
||||
|
||||
|
||||
stake_type = models.CharField('Тип', choices=StakeEnum.choices,default=StakeEnum.DAY1, max_length=250)
|
||||
percent = models.IntegerField('Процент бонусов', null=True, blank=True)
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.stake_type} - {self.percent}%"
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Stake'
|
||||
verbose_name_plural = 'Stake'
|
||||
|
||||
class UserStake(models.Model):
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||
balance = models.ForeignKey(Balance, on_delete=models.CASCADE)
|
||||
stake = models.ForeignKey(Stake, on_delete=models.CASCADE)
|
||||
amount = models.DecimalField('Сумма',max_digits=30, decimal_places=4)
|
||||
is_active = models.BooleanField('Автивен', default=True)
|
||||
start_date = models.DateTimeField('Время начала', auto_now=True)
|
||||
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user.username} - {self.amount} коинов"
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Пользовательский Stake'
|
||||
verbose_name_plural = 'Пользовательские Stake'
|
14
stacking/serializers.py
Normal file
14
stacking/serializers.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from rest_framework import serializers
|
||||
from .models import UserStake, Stake
|
||||
|
||||
class UserStakeSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = UserStake
|
||||
fields = '__all__'
|
||||
|
||||
class StakeSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Stake
|
||||
fields = '__all__'
|
||||
|
||||
|
3
stacking/tests.py
Normal file
3
stacking/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
14
stacking/views.py
Normal file
14
stacking/views.py
Normal file
@@ -0,0 +1,14 @@
|
||||
from rest_framework import viewsets
|
||||
from .models import UserStake, Stake
|
||||
from .serializers import UserStakeSerializer, StakeSerializer
|
||||
|
||||
|
||||
|
||||
class UserStakeViewSet(viewsets.ModelViewSet):
|
||||
queryset = UserStake.objects.all()
|
||||
serializer_class = UserStakeSerializer
|
||||
class StakeViewSet(viewsets.ModelViewSet):
|
||||
queryset = Stake.objects.all()
|
||||
serializer_class = StakeSerializer
|
||||
|
||||
|
Reference in New Issue
Block a user