Skip to content

Commit

Permalink
solid audit projects dev (#42)
Browse files Browse the repository at this point in the history
Co-authored-by: guoshijiang <[email protected]>
  • Loading branch information
guoshijiang and guoshijiang authored Jun 7, 2024
1 parent 2425dba commit 44e9033
Show file tree
Hide file tree
Showing 13 changed files with 579 additions and 0 deletions.
Empty file added api/solid/__init__.py
Empty file.
59 changes: 59 additions & 0 deletions api/solid/api_v1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# encoding=utf-8

import json
import uuid

from common.helpers import (
ok_json,
error_json
)
from solid.models import (
ServiceType,
AuditProject,
CoreMember,
LoadBoard
)


# @check_api_token
def get_services_type(request):
sr_list = ServiceType.objects.all().order_by("-id")
sr_response = []
for sr in sr_list:
sr_response.append(sr.as_dict())
return ok_json(sr_response)


# @check_api_token
def get_audit_projects(request):
params = json.loads(request.body.decode())
service_type_id = params.get("service_type_id", 0)
status = params.get("status", "all")
if service_type_id not in ["0", 0] and status in ["all", "All", "ALL"]:
audit_project_lists = AuditProject.objects.filter(service_type__id=service_type_id).order_by("id").all()
elif status in ["all", "All", "ALL"]:
audit_project_lists = AuditProject.objects.all().order_by("id").all()
else:
audit_project_lists = AuditProject.objects.filter(status='Ongoing').order_by("id").all()
projects_ret_lists = []
for ap in audit_project_lists:
projects_ret_lists.append(ap.as_dict())
return ok_json(projects_ret_lists)


# @check_api_token
def get_core_members(request):
cm_lists = CoreMember.objects.all().order_by("-id").all()
cm_ret_lists = []
for cm in cm_lists:
cm_ret_lists.append(cm.as_dict())
return ok_json(cm_ret_lists)


# @check_api_token
def get_leadboard_list(request):
leadboard_lists = LoadBoard.objects.all().order_by("-payouts")
ret_leadboard_lists = []
for ld in leadboard_lists:
ret_leadboard_lists.append(ld.as_dict())
return ok_json(ret_leadboard_lists)
13 changes: 13 additions & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@
get_l2_withdraw_record
)

from api.solid.api_v1 import (
get_services_type,
get_core_members,
get_audit_projects,
get_leadboard_list
)


urlpatterns = [
# Hd wallet module
Expand Down Expand Up @@ -147,4 +154,10 @@
path(r'get_l2_stake_record', get_l2_stake_record, name='get_l2_stake_record'),
path(r'get_l2_unstake_record', get_l2_unstake_record, name='get_l2_unstake_record'),
path(r'get_l2_withdraw_record', get_l2_withdraw_record, name='get_l2_withdraw_record'),

# solid
path(r'get_services_type', get_services_type, name='get_services_type'),
path(r'get_core_members', get_core_members, name='get_core_members'),
path(r'get_audit_projects', get_audit_projects, name='get_audit_projects'),
path(r'get_leadboard_list', get_leadboard_list, name='get_leadboard_list'),
]
1 change: 1 addition & 0 deletions hailstone/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'airdrop',
'website',
'l3staking',
"solid",
]

MIDDLEWARE = [
Expand Down
Empty file added solid/__init__.py
Empty file.
29 changes: 29 additions & 0 deletions solid/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# encoding=utf-8

from django.contrib import admin
from solid.models import (
ServiceType,
AuditProject,
CoreMember,
LoadBoard
)

@admin.register(ServiceType)
class ServiceTypeAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'icon', 'detail')


@admin.register(AuditProject)
class AuditProjectAdmin(admin.ModelAdmin):
list_display = ('id', 'name', 'status', 'report_link')


@admin.register(CoreMember)
class CoreMemberAdmin(admin.ModelAdmin):
list_display = ('id', 'name')


@admin.register(LoadBoard)
class LoadBoardAdmin(admin.ModelAdmin):
list_display = ('id', 'competitor', 'payouts')

6 changes: 6 additions & 0 deletions solid/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class SolidConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'solid'
89 changes: 89 additions & 0 deletions solid/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Generated by Django 4.1.1 on 2024-06-07 05:32

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='CoreMember',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.CharField(blank=True, max_length=100, null=True, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
('name', models.CharField(default='Social', max_length=100, verbose_name='成员姓名')),
('photo', models.ImageField(blank=True, null=True, upload_to='member/%Y/%m/%d/')),
('detail', models.CharField(default='unknown', max_length=500, verbose_name='成员简介')),
],
options={
'verbose_name': 'CoreMember',
'verbose_name_plural': 'CoreMember',
},
),
migrations.CreateModel(
name='LoadBoard',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.CharField(blank=True, max_length=100, null=True, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
('competitor', models.CharField(default='unknown', max_length=500, verbose_name='审计员名称')),
('payouts', models.CharField(default='0', max_length=500, verbose_name='获取的总收益')),
('total_findings', models.CharField(default='0', max_length=500, verbose_name='找到的总问题数')),
('solo', models.CharField(default='0', max_length=500, verbose_name='个人找到的问题')),
('high', models.CharField(default='0', max_length=500, verbose_name='找到的高危漏洞数量')),
('med', models.CharField(default='0', max_length=500, verbose_name='找到的中危漏洞数量')),
('solo_high', models.CharField(default='0', max_length=500, verbose_name='个人找到的高危漏洞数量')),
('solo_med', models.CharField(default='0', max_length=500, verbose_name='个人找到的中危漏洞数量')),
('first_place', models.CharField(default='0', max_length=500, verbose_name='第一位置发现数量')),
],
options={
'verbose_name': 'LeadBoard',
'verbose_name_plural': 'LeadBoard',
},
),
migrations.CreateModel(
name='ServiceType',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.CharField(blank=True, max_length=100, null=True, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
('name', models.CharField(default='', max_length=100, verbose_name='服务名称')),
('icon', models.ImageField(blank=True, null=True, upload_to='icon/%Y/%m/%d/')),
('detail', models.CharField(default='unknown', max_length=500, verbose_name='服务描述')),
],
options={
'verbose_name': 'ServiceType',
'verbose_name_plural': 'ServiceType',
},
),
migrations.CreateModel(
name='AuditProject',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.CharField(blank=True, max_length=100, null=True, unique=True)),
('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
('updated_at', models.DateTimeField(auto_now=True, db_index=True)),
('name', models.CharField(default='', max_length=100, verbose_name='审计项目的名称')),
('photo', models.ImageField(blank=True, null=True, upload_to='audit/%Y/%m/%d/')),
('status', models.CharField(choices=[('Prepare', 'Prepare'), ('Ongoing', 'Ongoing'), ('End', 'End')], default='Ongoing', max_length=100, verbose_name='项目状体')),
('project_link', models.CharField(blank=True, default='', max_length=100, null=True, verbose_name='项目链接')),
('detail', models.CharField(default='unknown', max_length=500, verbose_name='项目描述')),
('report_link', models.CharField(blank=True, default='', max_length=100, null=True, verbose_name='项目链接')),
('service_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='services_type', to='solid.servicetype', verbose_name='项目类别')),
],
options={
'verbose_name': 'AuditProject',
'verbose_name_plural': 'AuditProject',
},
),
]
Empty file added solid/migrations/__init__.py
Empty file.
Loading

0 comments on commit 44e9033

Please sign in to comment.