alter to text field

This commit is contained in:
virusdefender 2018-05-01 12:54:27 +08:00
parent 5cb907fa94
commit 3bb3becfcf
15 changed files with 381 additions and 43 deletions

View File

@ -0,0 +1,85 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0009_auto_20171125_1514'),
]
operations = [
migrations.AlterField(
model_name='user',
name='admin_type',
field=models.TextField(default='Regular User'),
),
migrations.AlterField(
model_name='user',
name='auth_token',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='user',
name='open_api_appkey',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='user',
name='problem_permission',
field=models.TextField(default='None'),
),
migrations.AlterField(
model_name='user',
name='reset_password_token',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='user',
name='tfa_token',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='user',
name='username',
field=models.TextField(unique=True),
),
migrations.AlterField(
model_name='userprofile',
name='avatar',
field=models.TextField(default='/public/avatar/default.png'),
),
migrations.AlterField(
model_name='userprofile',
name='blog',
field=models.URLField(null=True),
),
migrations.AlterField(
model_name='userprofile',
name='github',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='userprofile',
name='major',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='userprofile',
name='mood',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='userprofile',
name='real_name',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='userprofile',
name='school',
field=models.TextField(null=True),
),
]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:56
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('account', '0010_auto_20180501_0436'),
]
operations = [
migrations.AlterField(
model_name='user',
name='email',
field=models.TextField(null=True),
),
]

View File

@ -24,22 +24,22 @@ class UserManager(models.Manager):
class User(AbstractBaseUser):
username = models.CharField(max_length=32, unique=True)
email = models.EmailField(max_length=64, null=True)
username = models.TextField(unique=True)
email = models.TextField(null=True)
create_time = models.DateTimeField(auto_now_add=True, null=True)
# One of UserType
admin_type = models.CharField(max_length=32, default=AdminType.REGULAR_USER)
problem_permission = models.CharField(max_length=32, default=ProblemPermission.NONE)
reset_password_token = models.CharField(max_length=32, null=True)
admin_type = models.TextField(default=AdminType.REGULAR_USER)
problem_permission = models.TextField(default=ProblemPermission.NONE)
reset_password_token = models.TextField(null=True)
reset_password_token_expire_time = models.DateTimeField(null=True)
# SSO auth token
auth_token = models.CharField(max_length=32, null=True)
auth_token = models.TextField(null=True)
two_factor_auth = models.BooleanField(default=False)
tfa_token = models.CharField(max_length=32, null=True)
tfa_token = models.TextField(null=True)
session_keys = JSONField(default=list)
# open api key
open_api = models.BooleanField(default=False)
open_api_appkey = models.CharField(max_length=32, null=True)
open_api_appkey = models.TextField(null=True)
is_disabled = models.BooleanField(default=False)
USERNAME_FIELD = "username"
@ -87,13 +87,13 @@ class UserProfile(models.Model):
# like acm_problems_status, merely add "score" field
oi_problems_status = JSONField(default=dict)
real_name = models.CharField(max_length=32, blank=True, null=True)
avatar = models.CharField(max_length=256, default=f"{settings.AVATAR_URI_PREFIX}/default.png")
blog = models.URLField(blank=True, null=True)
mood = models.CharField(max_length=256, blank=True, null=True)
github = models.CharField(max_length=64, blank=True, null=True)
school = models.CharField(max_length=64, blank=True, null=True)
major = models.CharField(max_length=64, blank=True, null=True)
real_name = models.TextField(null=True)
avatar = models.TextField(default=f"{settings.AVATAR_URI_PREFIX}/default.png")
blog = models.URLField(null=True)
mood = models.TextField(null=True)
github = models.TextField(null=True)
school = models.TextField(null=True)
major = models.TextField(null=True)
# for ACM
accepted_number = models.IntegerField(default=0)
# for OI

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('announcement', '0002_auto_20171011_1214'),
]
operations = [
migrations.AlterField(
model_name='announcement',
name='title',
field=models.TextField(),
),
]

View File

@ -5,7 +5,7 @@ from utils.models import RichTextField
class Announcement(models.Model):
title = models.CharField(max_length=64)
title = models.TextField()
# HTML
content = RichTextField()
create_time = models.DateTimeField(auto_now_add=True)

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('conf', '0003_judgeserver_is_disabled'),
]
operations = [
migrations.AlterField(
model_name='judgeserver',
name='hostname',
field=models.TextField(),
),
migrations.AlterField(
model_name='judgeserver',
name='ip',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='judgeserver',
name='judger_version',
field=models.TextField(),
),
migrations.AlterField(
model_name='judgeserver',
name='service_url',
field=models.TextField(null=True),
),
]

View File

@ -3,16 +3,16 @@ from django.utils import timezone
class JudgeServer(models.Model):
hostname = models.CharField(max_length=128)
ip = models.CharField(max_length=32, blank=True, null=True)
judger_version = models.CharField(max_length=32)
hostname = models.TextField()
ip = models.TextField(null=True)
judger_version = models.TextField()
cpu_core = models.IntegerField()
memory_usage = models.FloatField()
cpu_usage = models.FloatField()
last_heartbeat = models.DateTimeField()
create_time = models.DateTimeField(auto_now_add=True)
task_number = models.IntegerField(default=0)
service_url = models.CharField(max_length=256, blank=True, null=True)
service_url = models.TextField(null=True)
is_disabled = models.BooleanField(default=False)
@property

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('contest', '0008_contest_allowed_ip_ranges'),
]
operations = [
migrations.AlterField(
model_name='contest',
name='password',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='contest',
name='rule_type',
field=models.TextField(),
),
migrations.AlterField(
model_name='contest',
name='title',
field=models.TextField(),
),
migrations.AlterField(
model_name='contestannouncement',
name='title',
field=models.TextField(),
),
]

View File

@ -9,13 +9,13 @@ from utils.models import RichTextField
class Contest(models.Model):
title = models.CharField(max_length=40)
title = models.TextField()
description = RichTextField()
# show real time rank or cached rank
real_time_rank = models.BooleanField()
password = models.CharField(max_length=30, blank=True, null=True)
password = models.TextField(null=True)
# enum of ContestRuleType
rule_type = models.CharField(max_length=36)
rule_type = models.TextField()
start_time = models.DateTimeField()
end_time = models.DateTimeField()
create_time = models.DateTimeField(auto_now_add=True)
@ -88,7 +88,7 @@ class OIContestRank(AbstractContestRank):
class ContestAnnouncement(models.Model):
contest = models.ForeignKey(Contest)
title = models.CharField(max_length=128)
title = models.TextField()
content = RichTextField()
created_by = models.ForeignKey(User)
visible = models.BooleanField(default=True)

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('options', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='sysoptions',
name='key',
field=models.TextField(db_index=True, unique=True),
),
]

View File

@ -3,5 +3,5 @@ from utils.models import JSONField
class SysOptions(models.Model):
key = models.CharField(max_length=128, unique=True, db_index=True)
key = models.TextField(unique=True, db_index=True)
value = JSONField()

View File

@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:36
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import utils.models
class Migration(migrations.Migration):
dependencies = [
('problem', '0011_fix_problem_ac_count'),
]
operations = [
migrations.AlterField(
model_name='problem',
name='_id',
field=models.TextField(db_index=True),
),
migrations.AlterField(
model_name='problem',
name='contest',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='contest.Contest'),
),
migrations.AlterField(
model_name='problem',
name='difficulty',
field=models.TextField(),
),
migrations.AlterField(
model_name='problem',
name='hint',
field=utils.models.RichTextField(null=True),
),
migrations.AlterField(
model_name='problem',
name='last_update_time',
field=models.DateTimeField(null=True),
),
migrations.AlterField(
model_name='problem',
name='rule_type',
field=models.TextField(),
),
migrations.AlterField(
model_name='problem',
name='source',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='problem',
name='spj_code',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='problem',
name='spj_language',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='problem',
name='spj_version',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='problem',
name='test_case_id',
field=models.TextField(),
),
migrations.AlterField(
model_name='problem',
name='title',
field=models.TextField(),
),
migrations.AlterField(
model_name='problem',
name='total_score',
field=models.IntegerField(default=0),
),
migrations.AlterField(
model_name='problemtag',
name='name',
field=models.TextField(),
),
]

View File

@ -8,7 +8,7 @@ from utils.constants import Choices
class ProblemTag(models.Model):
name = models.CharField(max_length=30)
name = models.TextField()
class Meta:
db_table = "problem_tag"
@ -27,26 +27,26 @@ class ProblemDifficulty(object):
class Problem(models.Model):
# display ID
_id = models.CharField(max_length=24, db_index=True)
contest = models.ForeignKey(Contest, null=True, blank=True)
_id = models.TextField(db_index=True)
contest = models.ForeignKey(Contest, null=True)
# for contest problem
is_public = models.BooleanField(default=False)
title = models.CharField(max_length=128)
title = models.TextField()
# HTML
description = RichTextField()
input_description = RichTextField()
output_description = RichTextField()
# [{input: "test", output: "123"}, {input: "test123", output: "456"}]
samples = JSONField()
test_case_id = models.CharField(max_length=32)
test_case_id = models.TextField()
# [{"input_name": "1.in", "output_name": "1.out", "score": 0}]
test_case_score = JSONField()
hint = RichTextField(blank=True, null=True)
hint = RichTextField(null=True)
languages = JSONField()
template = JSONField()
create_time = models.DateTimeField(auto_now_add=True)
# we can not use auto_now here
last_update_time = models.DateTimeField(blank=True, null=True)
last_update_time = models.DateTimeField(null=True)
created_by = models.ForeignKey(User)
# ms
time_limit = models.IntegerField()
@ -54,17 +54,17 @@ class Problem(models.Model):
memory_limit = models.IntegerField()
# special judge related
spj = models.BooleanField(default=False)
spj_language = models.CharField(max_length=32, blank=True, null=True)
spj_code = models.TextField(blank=True, null=True)
spj_version = models.CharField(max_length=32, blank=True, null=True)
spj_language = models.TextField(null=True)
spj_code = models.TextField(null=True)
spj_version = models.TextField(null=True)
spj_compile_ok = models.BooleanField(default=False)
rule_type = models.CharField(max_length=32)
rule_type = models.TextField()
visible = models.BooleanField(default=True)
difficulty = models.CharField(max_length=32)
difficulty = models.TextField()
tags = models.ManyToManyField(ProblemTag)
source = models.CharField(max_length=200, blank=True, null=True)
source = models.TextField(null=True)
# for OI mode
total_score = models.IntegerField(default=0, blank=True)
total_score = models.IntegerField(default=0)
submission_number = models.BigIntegerField(default=0)
accepted_number = models.BigIntegerField(default=0)
# {JudgeStatus.ACCEPTED: 3, JudgeStaus.WRONG_ANSWER: 11}, the number means count

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2018-05-01 04:36
from __future__ import unicode_literals
from django.db import migrations, models
import utils.shortcuts
class Migration(migrations.Migration):
dependencies = [
('submission', '0011_fix_submission_number'),
]
operations = [
migrations.AlterField(
model_name='submission',
name='id',
field=models.TextField(db_index=True, default=utils.shortcuts.rand_str, primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='submission',
name='ip',
field=models.TextField(null=True),
),
migrations.AlterField(
model_name='submission',
name='language',
field=models.TextField(),
),
migrations.AlterField(
model_name='submission',
name='username',
field=models.TextField(),
),
]

View File

@ -21,22 +21,22 @@ class JudgeStatus:
class Submission(models.Model):
id = models.CharField(max_length=32, default=rand_str, primary_key=True, db_index=True)
id = models.TextField(default=rand_str, primary_key=True, db_index=True)
contest = models.ForeignKey(Contest, null=True)
problem = models.ForeignKey(Problem)
create_time = models.DateTimeField(auto_now_add=True)
user_id = models.IntegerField(db_index=True)
username = models.CharField(max_length=30)
username = models.TextField()
code = models.TextField()
result = models.IntegerField(db_index=True, default=JudgeStatus.PENDING)
# 从JudgeServer返回的判题详情
info = JSONField(default=dict)
language = models.CharField(max_length=20)
language = models.TextField()
shared = models.BooleanField(default=False)
# 存储该提交所用时间和内存值,方便提交列表显示
# {time_cost: "", memory_cost: "", err_info: "", score: 0}
statistic_info = JSONField(default=dict)
ip = models.CharField(max_length=32, null=True, blank=True)
ip = models.TextField(null=True)
def check_user_permission(self, user, check_share=True):
return self.user_id == user.id or \