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
1d7637c9
Kaydet (Commit)
1d7637c9
authored
May 04, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
extended list
üst
3c979907
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
13 deletions
+58
-13
admin.py
social/admin.py
+2
-1
0001_initial.py
social/migrations/0001_initial.py
+10
-3
0002_snippet.py
social/migrations/0002_snippet.py
+22
-0
models.py
social/models.py
+9
-5
base.html
social/templates/base.html
+2
-0
home.html
social/templates/home.html
+6
-1
snippet.html
social/templates/repr/snippet.html
+5
-0
views.py
social/views.py
+2
-3
No files found.
social/admin.py
Dosyayı görüntüle @
1d7637c9
...
...
@@ -3,7 +3,7 @@ from django.contrib.auth import get_user_model
from
django.contrib.auth.admin
import
UserAdmin
from
social.forms
import
SocialUserCreationForm
,
SocialUserChangeForm
from
social.models
import
SocialUser
,
Post
from
social.models
import
SocialUser
,
Post
,
Snippet
class
SocialUserAdmin
(
UserAdmin
):
add_form
=
SocialUserCreationForm
...
...
@@ -13,3 +13,4 @@ class SocialUserAdmin(UserAdmin):
admin
.
site
.
register
(
SocialUser
,
SocialUserAdmin
)
admin
.
site
.
register
(
Post
)
admin
.
site
.
register
(
Snippet
)
social/migrations/0001_initial.py
Dosyayı görüntüle @
1d7637c9
# Generated by Django 2.2.1 on 2019-05-04 1
5:47
# Generated by Django 2.2.1 on 2019-05-04 1
7:18
from
django.conf
import
settings
import
django.contrib.auth.models
...
...
@@ -44,10 +44,9 @@ class Migration(migrations.Migration):
],
),
migrations
.
CreateModel
(
name
=
'
Post
'
,
name
=
'
Sharable
'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'text'
,
models
.
TextField
(
max_length
=
288
)),
(
'pub_date'
,
models
.
TimeField
(
auto_now
=
True
)),
(
'author'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
settings
.
AUTH_USER_MODEL
)),
],
...
...
@@ -55,4 +54,12 @@ class Migration(migrations.Migration):
'ordering'
:
[
'pub_date'
],
},
),
migrations
.
CreateModel
(
name
=
'Post'
,
fields
=
[
(
'sharable_ptr'
,
models
.
OneToOneField
(
auto_created
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
parent_link
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'social.Sharable'
)),
(
'text'
,
models
.
TextField
(
max_length
=
288
)),
],
bases
=
(
'social.sharable'
,),
),
]
social/migrations/0002_snippet.py
0 → 100644
Dosyayı görüntüle @
1d7637c9
# Generated by Django 2.2.1 on 2019-05-04 17:26
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'social'
,
'0001_initial'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Snippet'
,
fields
=
[
(
'sharable_ptr'
,
models
.
OneToOneField
(
auto_created
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
parent_link
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'social.Sharable'
)),
(
'text'
,
models
.
TextField
()),
],
bases
=
(
'social.sharable'
,),
),
]
social/models.py
Dosyayı görüntüle @
1d7637c9
...
...
@@ -4,9 +4,8 @@ from django.contrib.auth.models import AbstractUser
class
SocialUser
(
AbstractUser
):
pass
class
Post
(
models
.
Model
):
class
Sharable
(
models
.
Model
):
class
Meta
:
ordering
=
[
'pub_date'
]
...
...
@@ -15,8 +14,13 @@ class Post(models.Model):
on_delete
=
models
.
CASCADE
,
)
text
=
models
.
TextField
(
max_length
=
settings
.
MAX_POST_LENGTH
)
pub_date
=
models
.
TimeField
(
auto_now
=
True
)
def
__str__
(
self
):
return
f
"{self.author}#{self.id}"
return
f
"{self.__class__.__name__}@{self.author}"
class
Post
(
Sharable
):
text
=
models
.
TextField
(
max_length
=
settings
.
MAX_POST_LENGTH
)
class
Snippet
(
Sharable
):
text
=
models
.
TextField
()
social/templates/base.html
Dosyayı görüntüle @
1d7637c9
...
...
@@ -3,11 +3,13 @@
<head>
<meta
charset=
"utf-8"
>
<title>
{% block title %}Aspava{% endblock %}
</title>
{% block css %}{% endblock %}
</head>
<body>
<main>
{% block content %}
{% endblock %}
</main>
{% block js %}{% endblock %}
</body>
</html>
social/templates/home.html
Dosyayı görüntüle @
1d7637c9
{% extends 'base.html' %}
{% block title %}Home{% endblock %}
{% block css %}
<link
rel=
"stylesheet"
href=
"https://prismjs.com/themes/prism.css"
data-noprefix
/>
{% endblock %}
{% block content %}
{% if user.is_authenticated %}
Hi {{ user.username }}!
...
...
@@ -15,3 +17,6 @@
<a
href=
"{% url 'login' %}"
>
login
</a>
{% endif %}
{% endblock %}
{% block js %}
<script
src=
"https://prismjs.com/prism.js"
></script>
{% endblock %}
social/templates/repr/snippet.html
0 → 100644
Dosyayı görüntüle @
1d7637c9
<div>
<pre>
<code
class=
"language-py"
>
{{ item.text }}
</code>
</pre>
</div>
social/views.py
Dosyayı görüntüle @
1d7637c9
...
...
@@ -2,7 +2,7 @@ from django.contrib.auth.forms import UserCreationForm
from
django.urls
import
reverse_lazy
from
django.views.generic
import
CreateView
,
ListView
from
django.views.generic.base
import
TemplateView
from
social.models
import
Post
from
social.models
import
Post
,
Snippet
from
operator
import
or_
from
functools
import
wraps
,
reduce
...
...
@@ -20,14 +20,13 @@ def ret_or_super(func):
return
wrapper
class
ExtendedListView
(
ListView
):
@ret_or_super
def
get_queryset
(
self
):
queryset
=
reduce
(
or_
,
map
(
lambda
model
:
model
.
_default_manager
.
all
(),
self
.
models
))
return
queryset
class
Home
(
ExtendedListView
):
models
=
Post
,
models
=
Post
,
Snippet
template_name
=
'home.html'
context_object_name
=
'feed'
...
...
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