Skip to content

Commit e33b85d

Browse files
committed
Init
0 parents  commit e33b85d

File tree

111 files changed

+1386
-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.

111 files changed

+1386
-0
lines changed

account/__init__.py

Whitespace-only changes.
175 Bytes
Binary file not shown.
508 Bytes
Binary file not shown.
397 Bytes
Binary file not shown.
920 Bytes
Binary file not shown.
1.87 KB
Binary file not shown.
810 Bytes
Binary file not shown.
1.05 KB
Binary file not shown.
2.19 KB
Binary file not shown.

account/admin.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.contrib import admin
2+
from .models import Profile
3+
4+
@admin.register(Profile)
5+
class ProfileAdmin(admin.ModelAdmin):
6+
list_display = ['user', 'date_of_birth', 'photo']

account/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AccountConfig(AppConfig):
5+
name = 'account'

account/authentication.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.contrib.auth.models import User
2+
3+
""" Выполняет аутентификацию пользователя по e-mail """
4+
5+
6+
class EmailAuthBackend(object):
7+
def authenticate(self, request, username=None, password=None):
8+
try:
9+
user = User.objects.get(email=username)
10+
if user.check_password(password):
11+
return user
12+
return None
13+
except User.DoesNotExist:
14+
return None
15+
16+
def get_user(self, user_id):
17+
try:
18+
return User.objects.get(pk=user_id)
19+
except User.DoesNotExist:
20+
return None

account/forms.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from django import forms
2+
from django.contrib.auth.models import User
3+
from .models import Profile
4+
5+
""" Форма авторизации пользователя"""
6+
class LoginForm(forms.Form):
7+
username = forms.CharField()
8+
password = forms.CharField(widget=forms.PasswordInput)
9+
10+
11+
""" Форма регистрации пользователя """
12+
class UserRegistrationForm(forms.ModelForm):
13+
password = forms.CharField(label='Password', widget=forms.PasswordInput)
14+
password2 = forms.CharField(label='Repeat password', widget=forms.PasswordInput)
15+
16+
class Meta:
17+
model = User
18+
fields = ('username', 'first_name', 'email')
19+
20+
def clean_password2(self):
21+
cd = self.cleaned_data
22+
if cd['password'] != cd['password2']:
23+
raise forms.ValidationError('Passwords don\'t match.')
24+
return cd['password2']
25+
26+
""" Форма редактирования основной информации профиля """
27+
class UserEditForm(forms.ModelForm):
28+
class Meta:
29+
model = User
30+
fields = ('first_name', 'last_name', 'email')
31+
32+
33+
""" Форма редактирования дополнительной информации профиля """
34+
class ProfileEditForm(forms.ModelForm):
35+
class Meta:
36+
model = Profile
37+
fields = ('date_of_birth', 'photo')
38+

account/migrations/0001_initial.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Generated by Django 2.0.5 on 2020-01-30 13:05
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='Profile',
19+
fields=[
20+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21+
('date_of_birth', models.DateField(blank=True, null=True)),
22+
('photo', models.ImageField(blank=True, upload_to='users/%Y/%m/%d/')),
23+
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
24+
],
25+
),
26+
]

account/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
Binary file not shown.

account/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.db import models
2+
from django.conf import settings
3+
4+
class Profile(models.Model):
5+
user = models.OneToOneField(settings.AUTH_USER_MODEL,
6+
on_delete=models.CASCADE)
7+
date_of_birth = models.DateField(blank=True, null=True)
8+
photo = models.ImageField(upload_to='users/%Y/%m/%d/', blank=True)
9+
10+
def __str__(self):
11+
return 'Profile for user {}'.format(self.user.username)

account/static/css/base.css

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
@import url(http://fonts.googleapis.com/css?family=Muli);
2+
3+
body {
4+
margin:0;
5+
padding:0;
6+
font-family:helvetica, sans-serif;
7+
}
8+
9+
p {
10+
line-height: 1.8;
11+
}
12+
13+
a {
14+
color:#12c064;
15+
text-decoration:none;
16+
}
17+
18+
a:hover {
19+
color:#00a74f;
20+
}
21+
22+
h1, h2, h3, h4, h5 , h6 { font-family: 'Muli', sans-serif; font-weight:normal; }
23+
24+
h1 {
25+
border-bottom:1px solid #bbb;
26+
padding:0 0 10px 0;
27+
margin:10px 0 20px 0;
28+
}
29+
30+
h2 {
31+
margin:30px 0 20px;
32+
}
33+
34+
ol {
35+
line-height:1.5;
36+
}
37+
38+
#header {
39+
padding:10px 100px;
40+
font-size:14px;
41+
background:#12c064;
42+
color:#fff;
43+
border-bottom:4px solid #1cdf78;
44+
overflow:auto;
45+
}
46+
47+
#header .logo {
48+
font-family: 'Muli', sans-serif;
49+
float:left;
50+
color:#f3f7cc;
51+
font-size:20px;
52+
margin-right:10%;
53+
}
54+
55+
#header ul.menu {
56+
list-style:none;
57+
float:left;
58+
margin:0;
59+
padding:0;
60+
}
61+
#header ul.menu li {
62+
float:left;
63+
padding:4px 10px;
64+
}
65+
66+
#header ul.menu li.selected a, #header ul.menu li.selected a:hover {
67+
color:#1b6d32;
68+
font-weight:bold;
69+
}
70+
71+
#header a {
72+
color:#f3f7cc;
73+
}
74+
#header a:hover {
75+
color:#fff;
76+
}
77+
78+
#header .user {
79+
float:right;
80+
padding-top:4px;
81+
}
82+
83+
#content {
84+
padding:30px 100px;
85+
}
86+
87+
/* forms */
88+
form {
89+
overflow:auto;
90+
}
91+
92+
form p {
93+
width:100%;
94+
overflow:auto;
95+
}
96+
97+
label {
98+
float:left;
99+
clear:both;
100+
color:#333;
101+
margin-bottom:4px;
102+
}
103+
input, textarea {
104+
clear:both;
105+
float:left;
106+
margin:0 0 10px;
107+
background:#efefef;
108+
border:0;
109+
padding:6px 10px;
110+
font-size:14px;
111+
}
112+
input[type=submit], a.button {
113+
font-weight:bold;
114+
background:#12c064;
115+
color:#fff;
116+
padding:10px 20px;
117+
font-size:14px;
118+
text-transform:uppercase;
119+
}
120+
.errorlist {
121+
color:#cc0033;
122+
float:left;
123+
clear:both;
124+
padding-left:10px;
125+
}
126+
.helptext {
127+
margin:0 0 20px 0;
128+
color:#aaa;
129+
clear:both;
130+
float:left;
131+
font-size:13px;
132+
}
133+
/* messages */
134+
ul.messages {
135+
margin:10px 100px;
136+
padding:0;
137+
list-style-type:
138+
none;
139+
}
140+
ul.messages li.success,
141+
ul.messages li.warning,
142+
ul.messages li.error,
143+
ul.messages li.info {
144+
margin:0;
145+
padding:14px 20px;
146+
list-style:none;
147+
color:#fff;
148+
}
149+
150+
ul.messages li.success { background:#81ce81; }
151+
ul.messages li.success a { color:#0ac33e; }
152+
153+
ul.messages li.error { background:#a30029; color:#e9828e; }
154+
ul.messages li.error a { color:#e9828e; }
155+
156+
ul.messages li.info { background:#faffae; color:#696b4e; }
157+
ul.messages li.info a { color:#1586de; }
158+
159+
ul.messages li.warning { background:#de9404; }
160+
ul.messages li.warning a { color:#f49000; }
161+
162+
ul.messages li a.close {
163+
margin:0;
164+
float:right;
165+
opacity:1;
166+
border:0;
167+
box-shadow:none;
168+
text-shadow:none;
169+
}
170+
171+
.login-form {
172+
float:left;
173+
}
174+
175+
/* social-auth */
176+
.social {
177+
float:right;
178+
}
179+
.social li {
180+
list-style:none;
181+
padding:10px 20px;
182+
margin:0 0 10px 0;
183+
}
184+
.social li a {
185+
width:100%;
186+
height:100%;
187+
display:block;
188+
color:#fff;
189+
}
190+
.social li.facebook { background:#3b5399; }
191+
.social li.twitter { background:#00cffa; }
192+
.social li.google { background:#de1710; }
193+
194+
195+
/* images */
196+
197+
.image-preview, .image-detail {
198+
max-width:300px;
199+
float:left;
200+
margin:0 20px 20px 0;
201+
}
202+
.image-detail { margin-top:20px; }
203+
.image-info div {
204+
padding:20px 0;
205+
overflow:auto;
206+
}
207+
.count {
208+
color:#aaa;
209+
border:3px solid #bbb;
210+
border-radius:26px;
211+
padding:10px 20px;
212+
margin:20px 10px 0;
213+
}
214+
a.like, a.follow { float:right; margin-top:-8px; }
215+
216+
#image-list { overflow:auto; }
217+
#image-list .image {
218+
float:left;
219+
width:220px;
220+
height:300px;
221+
margin:0 10px 10px 10px;
222+
border-top:8px solid #12c064;
223+
background:#eee;
224+
}
225+
#image-list img { width:220px; height:220px; }
226+
#image-list .info { padding:10px; }
227+
#image-list .info a { color:#333; }
228+
.image-likes div {
229+
float:left;
230+
width:auto;
231+
padding:10px;
232+
text-align:center;
233+
}
234+
.image-likes img {
235+
width:120px;
236+
height:120px;
237+
border-radius:50%;
238+
}
239+
240+
/* users */
241+
#people-list img {
242+
width:180px;
243+
height:180px;
244+
border-radius:50%;
245+
margin-bottom:20px;
246+
}
247+
#people-list .user {
248+
width:180px;
249+
float:left;
250+
overflow:auto;
251+
padding:10px;
252+
}
253+
#people-list .info { text-align:center; }
254+
img.user-detail {
255+
border-radius:50%;
256+
float:left;
257+
}
258+
.profile-info {
259+
float:left;
260+
overflow:auto;
261+
margin-right:20px;
262+
}
263+
.image-container { margin-top:40px; }
264+
265+
/* actions */
266+
.action {
267+
clear:both;
268+
overflow:auto;
269+
}
270+
.action .images {
271+
float:left;
272+
margin:0 10px 10px 0;
273+
}
274+
.action .date {
275+
font-style:italic;
276+
color:#ccc;
277+
}

0 commit comments

Comments
 (0)