Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
A
Aspava
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
Aspava
Commits
ecbedb42
Kaydet (Commit)
ecbedb42
authored
May 07, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
default avatar system changed
üst
119ae653
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
51 additions
and
12 deletions
+51
-12
settings.py
aspava/settings.py
+1
-2
forms.py
social/forms.py
+2
-2
0006_auto_20190507_1848.py
social/migrations/0006_auto_20190507_1848.py
+24
-0
models.py
social/models.py
+7
-8
.png
social/static/img/avatars/.png
+0
-0
avatar_1.png
social/static/img/avatars/avatar_1.png
+0
-0
avatar_2.png
social/static/img/avatars/avatar_2.png
+0
-0
avatar_3.png
social/static/img/avatars/avatar_3.png
+0
-0
avatar_4.png
social/static/img/avatars/avatar_4.png
+0
-0
generate.py
social/static/img/avatars/generate.py
+17
-0
No files found.
aspava/settings.py
Dosyayı görüntüle @
ecbedb42
...
@@ -11,7 +11,6 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
...
@@ -11,7 +11,6 @@ https://docs.djangoproject.com/en/2.0/ref/settings/
"""
"""
import
os
import
os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
@@ -117,5 +116,5 @@ AUTH_USER_MODEL = 'social.SocialUser'
...
@@ -117,5 +116,5 @@ AUTH_USER_MODEL = 'social.SocialUser'
# Extra Settings
# Extra Settings
MAX_POST_LENGTH
=
144
*
2
MAX_POST_LENGTH
=
144
*
2
AVATAR
=
'http://www.iconarchive.com/download/i106224/papirus-team/papirus-apps/python.ico
'
AVATAR
_BASE
=
'img/avatars/avatar_{}.png
'
DESC
=
"Apparently, this user prefers to keep an air of mystery about them."
DESC
=
"Apparently, this user prefers to keep an air of mystery about them."
social/forms.py
Dosyayı görüntüle @
ecbedb42
...
@@ -9,12 +9,12 @@ from social.models import Post, Link, Snippet
...
@@ -9,12 +9,12 @@ from social.models import Post, Link, Snippet
class
SocialUserCreationForm
(
UserCreationForm
):
class
SocialUserCreationForm
(
UserCreationForm
):
class
Meta
:
class
Meta
:
model
=
get_user_model
()
model
=
get_user_model
()
fields
=
(
"username"
,
"email"
,
"avatar"
)
fields
=
(
"username"
,
"email"
)
class
SocialUserChangeForm
(
UserChangeForm
):
class
SocialUserChangeForm
(
UserChangeForm
):
class
Meta
:
class
Meta
:
model
=
get_user_model
()
model
=
get_user_model
()
fields
=
(
"username"
,
"email"
,
"avatar"
)
fields
=
(
"username"
,
"email"
)
class
CreatePostForm
(
forms
.
ModelForm
):
class
CreatePostForm
(
forms
.
ModelForm
):
class
Meta
:
class
Meta
:
...
...
social/migrations/0006_auto_20190507_1848.py
0 → 100644
Dosyayı görüntüle @
ecbedb42
# Generated by Django 2.2.1 on 2019-05-07 18:48
from
django.db
import
migrations
,
models
import
social.models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'social'
,
'0005_auto_20190506_0252'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'socialuser'
,
name
=
'avatar'
,
field
=
models
.
URLField
(
blank
=
True
,
default
=
social
.
models
.
get_avatar
),
),
migrations
.
AlterField
(
model_name
=
'socialuser'
,
name
=
'desc'
,
field
=
models
.
TextField
(
blank
=
True
,
default
=
'Apparently, this user prefers to keep an air of mystery about them.'
),
),
]
social/models.py
Dosyayı görüntüle @
ecbedb42
from
pathlib
import
Path
from
random
import
randint
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.auth.models
import
AbstractUser
from
django.contrib.auth.models
import
AbstractUser
from
django.db
import
models
from
django.db
import
models
def
get_avatar
():
class
SocialUser
(
AbstractUser
):
return
settings
.
STATIC_URL
/
Path
(
settings
.
AVATAR_BASE
.
format
(
randint
(
1
,
4
)))
avatar
=
models
.
URLField
(
blank
=
True
)
desc
=
models
.
TextField
(
blank
=
True
)
def
save
(
self
,
*
args
,
**
kwargs
):
class
SocialUser
(
AbstractUser
):
self
.
avatar
=
settings
.
AVATAR
avatar
=
models
.
URLField
(
blank
=
True
,
default
=
get_avatar
)
self
.
desc
=
settings
.
DESC
desc
=
models
.
TextField
(
blank
=
True
,
default
=
settings
.
DESC
)
super
()
.
save
(
*
args
,
**
kwargs
)
@property
@property
def
slug
(
self
):
def
slug
(
self
):
...
...
social/static/img/avatars/.png
0 → 100644
Dosyayı görüntüle @
ecbedb42
File added
social/static/img/avatars/avatar_1.png
0 → 100644
Dosyayı görüntüle @
ecbedb42
307 Bytes
social/static/img/avatars/avatar_2.png
0 → 100644
Dosyayı görüntüle @
ecbedb42
307 Bytes
social/static/img/avatars/avatar_3.png
0 → 100644
Dosyayı görüntüle @
ecbedb42
307 Bytes
social/static/img/avatars/avatar_4.png
0 → 100644
Dosyayı görüntüle @
ecbedb42
307 Bytes
social/static/img/avatars/generate.py
0 → 100644
Dosyayı görüntüle @
ecbedb42
from
subprocess
import
run
COLORS
=
(
"red"
,
"green"
,
"blue"
,
"yellow"
)
def
main
(
amount
:
int
=
4
,
size
:
int
=
400
)
->
None
:
"""Generates a set of avatars from pure
colors."""
for
color
,
opt
in
zip
(
COLORS
,
range
(
1
,
amount
+
1
)):
run
([
"convert"
,
f
"xc:{color}[{size}x{size}!]"
,
f
"avatar_{opt}.png"
])
if
__name__
==
"__main__"
:
import
sys
main
(
*
sys
.
argv
[
1
:])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment