Skip to content

Commit 1591b08

Browse files
committed
完成前端页面,建立数据库,完成基本页面跳转
0 parents  commit 1591b08

Some content is hidden

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

59 files changed

+2450
-0
lines changed

backend/__init__.py

Whitespace-only changes.
128 Bytes
Binary file not shown.
117 Bytes
Binary file not shown.
368 Bytes
Binary file not shown.
357 Bytes
Binary file not shown.
409 Bytes
Binary file not shown.
392 Bytes
Binary file not shown.
1.17 KB
Binary file not shown.
1.17 KB
Binary file not shown.
2.33 KB
Binary file not shown.
2.46 KB
Binary file not shown.
1014 Bytes
Binary file not shown.
1020 Bytes
Binary file not shown.
2.14 KB
Binary file not shown.
2.45 KB
Binary file not shown.
435 Bytes
Binary file not shown.
414 Bytes
Binary file not shown.
1.08 KB
Binary file not shown.
1.24 KB
Binary file not shown.
9.56 KB
Binary file not shown.
9.46 KB
Binary file not shown.

backend/admin.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from django.contrib import admin
2+
from backend.models import Picture, User, Favorite, Tag, PictoTag
3+
4+
# Register your models here.
5+
admin.site.register(Picture)
6+
admin.site.register(User)
7+
admin.site.register(Favorite)
8+
admin.site.register(Tag)
9+
admin.site.register(PictoTag)

backend/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class BackendConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'backend'

backend/models.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
from django.db import models
2+
from django.contrib.auth.models import AbstractUser
3+
from django.contrib.auth.hashers import make_password, check_password
4+
5+
6+
# Create your models here.
7+
8+
class User(AbstractUser):
9+
id = models.BigAutoField(primary_key=True)
10+
email = models.EmailField(null=True)
11+
birthday = models.CharField(max_length=15, null=True)
12+
sex = models.CharField(max_length=1, null=True, default='1')
13+
country = models.CharField(max_length=30, null=True)
14+
first_name = models.CharField(max_length=10, null=True)
15+
last_name = models.CharField(max_length=10, null=True)
16+
wechat = models.CharField(max_length=50, null=True)
17+
18+
19+
class Picture(models.Model):
20+
pid = models.AutoField(primary_key=True)
21+
img = models.ImageField(upload_to="pics")
22+
imgname = models.CharField(max_length=100, null=True)
23+
size = models.IntegerField()
24+
uploader = models.ForeignKey('User', on_delete=models.CASCADE)
25+
upload_time = models.DateTimeField(auto_now_add=True)
26+
num_like = models.IntegerField()
27+
num_star = models.IntegerField()
28+
num_view = models.IntegerField()
29+
30+
31+
class Favorite(models.Model):
32+
pid = models.ForeignKey('Picture', on_delete=models.CASCADE)
33+
user = models.ForeignKey('User', on_delete=models.CASCADE)
34+
35+
class Meta:
36+
constraints = [
37+
# complex primary key: promise combination is only one
38+
models.UniqueConstraint(fields=['pid', 'user'], name='favor_pic'),
39+
]
40+
41+
42+
class Tag(models.Model):
43+
tag_id = models.AutoField(primary_key=True)
44+
tname = models.CharField(max_length=20)
45+
46+
class Meta:
47+
constraints = [
48+
# complex primary key: promise combination is only one
49+
models.UniqueConstraint(fields=['tag_id', 'tname'], name='tag_id'),
50+
]
51+
52+
53+
class PictoTag(models.Model):
54+
pid = models.ForeignKey('Picture', on_delete=models.CASCADE)
55+
tag_id = models.ForeignKey('Tag', on_delete=models.CASCADE)
56+
57+
class Meta:
58+
constraints = [
59+
# complex primary key: promise combination is only one
60+
models.UniqueConstraint(fields=['pid', 'tag_id'], name='tag_pic'),
61+
]

backend/static/css/detail.css

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
* {
2+
margin: 0;
3+
padding: 0;
4+
}
5+
6+
html,
7+
body,
8+
#mask {
9+
width: 100%;
10+
height: 100%;
11+
}
12+
13+
#mask {
14+
background-color: #c9c9c9;
15+
position: relative;
16+
}
17+
18+
#mask .center {
19+
position: absolute;
20+
background-color: #fff;
21+
left: 50%;
22+
top: 50%;
23+
transform: translate(-50%, -50%);
24+
padding: 10px;
25+
}
26+
#mask .center .title {
27+
position: absolute;
28+
display: flex;
29+
align-items: center;
30+
height: 56px;
31+
top: -61px;
32+
left: 0;
33+
color: rgba(175, 47, 47, 0.8);
34+
font-size: 26px;
35+
font-weight: normal;
36+
background-color: white;
37+
padding: 5px 50px 0 10px;
38+
z-index: 2;
39+
}
40+
41+
#mask .center .title::before {
42+
content: "";
43+
position: absolute;
44+
width: 0;
45+
height: 0;
46+
border: 65px solid;
47+
border-color: transparent transparent white;
48+
top: -65px;
49+
right: -65px;
50+
z-index: 1;
51+
}
52+
53+
#mask .center > img {
54+
display: block;
55+
width: 1400px;
56+
height: 700px;
57+
}
58+
59+
#mask .center .detail {
60+
font-size: x-small;
61+
font-weight: 600;
62+
color: brown;
63+
}
64+
65+
#mask .center .detail #tag {
66+
font-size: x-small;
67+
font-weight: 600;
68+
color: brown;
69+
}
70+
71+
#delete img{
72+
width: 30px;
73+
height: 30px;
74+
}
75+
76+
#thumb img{
77+
width: 30px;
78+
height: 30px;
79+
}
80+
81+
#star img{
82+
width: 30px;
83+
height: 30px;
84+
}
85+
86+
.detail {
87+
float: left;
88+
}
89+
90+
.like {
91+
float: right;
92+
}

0 commit comments

Comments
 (0)