Skip to content

Commit

Permalink
add new field for api
Browse files Browse the repository at this point in the history
  • Loading branch information
guoshijiang committed Mar 14, 2024
1 parent ff25023 commit f3e8e9e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 4.1.1 on 2024-03-14 12:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('airdrop', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='projectinteraction',
name='icon',
field=models.ImageField(blank=True, null=True, upload_to='projects/%Y/%m/%d/', verbose_name='交互Icon'),
),
migrations.AddField(
model_name='projectinteraction',
name='link_url',
field=models.CharField(blank=True, max_length=200, verbose_name='交互链接'),
),
migrations.AddField(
model_name='projectinteraction',
name='step',
field=models.CharField(blank=True, max_length=100, unique=True, verbose_name='交互步骤'),
),
migrations.AlterField(
model_name='projectinteraction',
name='name',
field=models.CharField(blank=True, max_length=100, unique=True, verbose_name='交互名称'),
),
migrations.AlterField(
model_name='questions',
name='answer',
field=models.CharField(max_length=500, unique=True, verbose_name='问题答案'),
),
migrations.AlterField(
model_name='questions',
name='question',
field=models.CharField(max_length=200, unique=True, verbose_name='问题名称'),
),
]
30 changes: 28 additions & 2 deletions airdrop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class Meta:
def __str__(self):
return self.name

def get_invite_member_numbers(self):
return AirdropUser.objects.filter(uuid=self.uuid).count()

def as_dict(self):
return {
'id': self.id,
Expand All @@ -92,6 +95,7 @@ def as_dict(self):
'x_twitter': self.x_twitter,
'discord': self.discord,
'telegram': self.telegram,
'invite_total': self.get_invite_member_numbers(),
'info': self.info
}

Expand Down Expand Up @@ -138,16 +142,35 @@ def as_dict(self):


class ProjectInterAction(BaseModel):
step = models.CharField(
max_length=100,
unique=True,
blank=True,
verbose_name='交互步骤'
)
icon = models.ImageField(
upload_to='projects/%Y/%m/%d/',
blank=True,
null=True,
verbose_name='交互Icon'
)
name = models.CharField(
max_length=100,
unique=True,
blank=True,
verbose_name='交互名称'
)
describe = models.CharField(
max_length=200,
unique=True,
verbose_name='交互描述'
)
link_url = models.CharField(
max_length=200,
unique=False,
blank=True,
verbose_name='交互链接'
)
language = models.CharField(
max_length=100,
choices=LanguageChoice,
Expand Down Expand Up @@ -175,9 +198,12 @@ def __str__(self):
def as_dict(self):
return {
'id': self.id,
'step': self.step,
'name': self.name,
'icon': str(self.icon),
'describe': self.describe,
'type': self.type,
'link_url': self.link_url,
'language': self.language,
'points': self.max_points,
}
Expand All @@ -187,12 +213,12 @@ class Questions(BaseModel):
question = models.CharField(
max_length=200,
unique=True,
verbose_name='交互名称'
verbose_name='问题名称'
)
answer = models.CharField(
max_length=500,
unique=True,
verbose_name='交互名称'
verbose_name='问题答案'
)
language = models.CharField(
max_length=100,
Expand Down

0 comments on commit f3e8e9e

Please sign in to comment.