Skip to content

Commit 3dcca14

Browse files
committed
commit
1 parent 5a9985d commit 3dcca14

File tree

369 files changed

+151449
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

369 files changed

+151449
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

Gr33kLibrary/__init__.py

Whitespace-only changes.
148 Bytes
Binary file not shown.
189 Bytes
Binary file not shown.
2.75 KB
Binary file not shown.
2.77 KB
Binary file not shown.
3.52 KB
Binary file not shown.
44.2 KB
Binary file not shown.

Gr33kLibrary/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

Gr33kLibrary/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class Gr33KlibraryConfig(AppConfig):
5+
name = 'Gr33kLibrary'

Gr33kLibrary/func.py

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
from Gr33kLibrary.models import *
3+
import os
4+
import math
5+
import html
6+
import re
7+
8+
9+
def list2str(old_list:list):
10+
_str = ""
11+
for l in old_list:
12+
_str = _str + str(l) + ','
13+
return _str
14+
15+
16+
class Article_temp():
17+
article = None
18+
tags = []
19+
article_num = 0
20+
21+
def __init__(self,article,tags):
22+
self.tags = []
23+
self.article = article
24+
for tag in tags:
25+
try:
26+
tag_name = Tag.objects.get(id=int(tag)).name
27+
self.tags.append(tag_name)
28+
except:
29+
continue
30+
31+
32+
def wrire_file(img,path,img_name_new):
33+
destination = open(os.path.join(path, img_name_new), 'wb+')
34+
for chunk in img.chunks():
35+
destination.write(chunk)
36+
destination.close()
37+
38+
39+
40+
def convertBytes(bytes, lst=None):
41+
if lst is None:
42+
lst=['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB']
43+
i = int(math.floor( # 舍弃小数点,取小
44+
math.log(bytes, 1024) # 求对数(对数:若 a**b = N 则 b 叫做以 a 为底 N 的对数)
45+
))
46+
47+
if i >= len(lst):
48+
i = len(lst) - 1
49+
return ('%.2f' + " " + lst[i]) % (bytes/math.pow(1024, i))
50+
51+
class Author():
52+
author = None
53+
article_num = 0
54+
invitation_user = None
55+
56+
def __init__(self,author:Article,article_num:int,invitation_user):
57+
self.author = author
58+
self.article_num = article_num
59+
try:
60+
self.invitation_user = User.objects.get(id=int(invitation_user))
61+
except:
62+
self.invitation_user = None
63+
64+
65+
class Classify_temp():
66+
classify = None
67+
article_num = 0
68+
69+
def __init__(self,classify:Classify,article_num:int):
70+
self.classify = classify
71+
self.article_num = article_num
72+
73+
74+
class Tag_temp():
75+
tag = None
76+
article_num = 0
77+
78+
def __init__(self, tag: Tag, article_num: int):
79+
self.tag = tag
80+
self.article_num = article_num
81+
82+
83+
def get_tag_article(tag_id):
84+
s_tag = str(tag_id) + ','
85+
num = Article.objects.filter(state=3).filter(tags__contains=s_tag).all().count()
86+
return num
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 2.1.7 on 2020-12-15 04:36
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='User',
16+
fields=[
17+
('id', models.AutoField(primary_key=True, serialize=False)),
18+
('username', models.CharField(max_length=255, unique=True)),
19+
('password', models.CharField(max_length=255)),
20+
('email', models.CharField(max_length=255, null=True)),
21+
('name', models.CharField(max_length=255, null=True)),
22+
('is_lock', models.BooleanField(default=False)),
23+
('login_fail', models.IntegerField(default=0)),
24+
('invitation_code', models.CharField(max_length=255, null=True)),
25+
('invitation_user', models.IntegerField(null=True)),
26+
],
27+
),
28+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.7 on 2020-12-15 13:37
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='user',
15+
name='create_time',
16+
field=models.DateTimeField(auto_now=True),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Generated by Django 2.1.7 on 2020-12-16 14:30
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0002_user_create_time'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='Classify',
15+
fields=[
16+
('id', models.AutoField(primary_key=True, serialize=False)),
17+
('name', models.CharField(max_length=255, null=True)),
18+
('create_time', models.DateTimeField(auto_now=True)),
19+
],
20+
),
21+
migrations.CreateModel(
22+
name='Tag',
23+
fields=[
24+
('id', models.AutoField(primary_key=True, serialize=False)),
25+
('name', models.CharField(max_length=255, null=True)),
26+
('create_time', models.DateTimeField(auto_now=True)),
27+
],
28+
),
29+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.1.7 on 2020-12-16 14:35
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0003_classify_tag'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='classify',
15+
name='name',
16+
field=models.CharField(max_length=255, null=True, unique=True),
17+
),
18+
migrations.AlterField(
19+
model_name='tag',
20+
name='name',
21+
field=models.CharField(max_length=255, null=True, unique=True),
22+
),
23+
]
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 2.1.7 on 2020-12-16 15:20
2+
3+
from django.db import migrations, models
4+
import mdeditor.fields
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('Gr33kLibrary', '0004_auto_20201216_1435'),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Update_log',
16+
fields=[
17+
('id', models.AutoField(primary_key=True, serialize=False)),
18+
('create_time', models.DateTimeField(auto_now=True)),
19+
('content', mdeditor.fields.MDTextField()),
20+
],
21+
),
22+
]
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 12:39
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
import mdeditor.fields
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('Gr33kLibrary', '0005_update_log'),
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='Article',
17+
fields=[
18+
('id', models.AutoField(primary_key=True, serialize=False)),
19+
('tags', models.CharField(max_length=255, null=True)),
20+
('content', mdeditor.fields.MDTextField()),
21+
('title', models.CharField(max_length=255)),
22+
('create_time', models.DateTimeField(auto_now=True)),
23+
('update_time', models.DateTimeField(null=True)),
24+
('author', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='Gr33kLibrary.User')),
25+
('classify', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='Gr33kLibrary.Classify')),
26+
],
27+
),
28+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 12:41
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0006_article'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='article',
15+
name='state',
16+
field=models.IntegerField(default=0),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 13:27
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0007_article_state'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='article',
15+
name='create_time',
16+
field=models.DateTimeField(),
17+
),
18+
migrations.AlterField(
19+
model_name='article',
20+
name='update_time',
21+
field=models.DateTimeField(auto_now=True),
22+
),
23+
]

Gr33kLibrary/migrations/0009_tool.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 14:02
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0008_auto_20201217_1327'),
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='Tool',
15+
fields=[
16+
('id', models.AutoField(primary_key=True, serialize=False)),
17+
('create_time', models.DateTimeField()),
18+
('name', models.CharField(max_length=255)),
19+
('path', models.CharField(max_length=255)),
20+
],
21+
),
22+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 14:04
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0009_tool'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='tool',
15+
name='create_time',
16+
field=models.DateTimeField(auto_now=True),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 14:08
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('Gr33kLibrary', '0010_auto_20201217_1404'),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name='tool',
16+
name='upload_user',
17+
field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='Gr33kLibrary.User'),
18+
),
19+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 14:15
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0011_tool_upload_user'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='tool',
15+
name='file_size',
16+
field=models.IntegerField(default=0),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.7 on 2020-12-17 14:17
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('Gr33kLibrary', '0012_tool_file_size'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='tool',
15+
name='file_size',
16+
field=models.CharField(max_length=255, null=True),
17+
),
18+
]

0 commit comments

Comments
 (0)