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
5d9dc30a
Kaydet (Commit)
5d9dc30a
authored
5 years ago
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Syntax highlight, extended list view
üst
1d7637c9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
22 deletions
+22
-22
home.html
social/templates/home.html
+4
-2
snippet.html
social/templates/repr/snippet.html
+10
-3
views.py
social/views.py
+8
-17
No files found.
social/templates/home.html
Dosyayı görüntüle @
5d9dc30a
...
...
@@ -2,7 +2,8 @@
{% block title %}Home{% endblock %}
{% block css %}
<link
rel=
"stylesheet"
href=
"https://prismjs.com/themes/prism.css"
data-noprefix
/>
<link
rel=
"stylesheet"
href=
"//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css"
>
{% endblock %}
{% block content %}
{% if user.is_authenticated %}
...
...
@@ -18,5 +19,6 @@
{% endif %}
{% endblock %}
{% block js %}
<script
src=
"https://prismjs.com/prism.js"
></script>
<script
src=
"//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"
></script>
<script>
hljs
.
initHighlightingOnLoad
();
</script>
{% endblock %}
This diff is collapsed.
Click to expand it.
social/templates/repr/snippet.html
Dosyayı görüntüle @
5d9dc30a
<div>
<pre>
<code
class=
"language-py"
>
{{ item.text }}
</code>
</pre>
<fieldset>
<legend>
{{ item.author }}
</legend>
<pre>
<code
class=
"python"
>
{{ item.text }}
</code>
</pre>
<br>
-- wrote this at {{ item.pub_date }};
</fieldset>
</div>
This diff is collapsed.
Click to expand it.
social/views.py
Dosyayı görüntüle @
5d9dc30a
from
itertools
import
chain
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
,
Snippet
from
operator
import
or_
from
functools
import
wraps
,
reduce
def
ret_or_super
(
func
):
def
wrapper
(
*
args
,
**
kwargs
):
try
:
res
=
func
(
*
args
,
**
kwargs
)
except
:
self
=
args
[
0
]
res
=
getattr
(
super
(
self
.
__class__
,
self
),
func
.
__name__
)(
*
args
,
**
kwargs
)
return
res
return
wrapper
class
ExtendedListView
(
ListView
):
def
get_queryset
(
self
):
queryset
=
reduce
(
or_
,
map
(
lambda
model
:
model
.
_default_manager
.
all
(),
self
.
models
))
return
queryset
return
chain
.
from_iterable
(
map
(
lambda
model
:
model
.
_default_manager
.
all
(),
self
.
models
))
class
Home
(
ExtendedListView
):
models
=
Post
,
Snippet
template_name
=
'home.html'
context_object_name
=
'feed'
def
get_queryset
(
self
):
qs
=
list
(
super
()
.
get_queryset
())
qs
.
sort
(
key
=
(
lambda
item
:
item
.
pub_date
))
return
qs
class
Register
(
CreateView
):
form_class
=
UserCreationForm
success_url
=
reverse_lazy
(
'login'
)
...
...
This diff is collapsed.
Click to expand it.
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