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
eb75f115
Kaydet (Commit)
eb75f115
authored
May 06, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Ace code editor for snippets
üst
204a37b8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
6 deletions
+32
-6
Pipfile
Pipfile
+1
-0
Pipfile.lock
Pipfile.lock
+9
-1
settings.py
aspava/settings.py
+2
-1
forms.py
social/forms.py
+4
-0
base.html
social/templates/base.html
+1
-1
snippet.html
social/templates/forms/snippet.html
+1
-1
views.py
social/views.py
+14
-2
No files found.
Pipfile
Dosyayı görüntüle @
eb75f115
...
...
@@ -8,6 +8,7 @@ verify_ssl = true
[packages]
django = "*"
django-bootstrap4 = "*"
django-ace = "*"
[requires]
python_version = "3.7"
Pipfile.lock
Dosyayı görüntüle @
eb75f115
{
"_meta": {
"hash": {
"sha256": "
2d89fabddb89aa5f1cb3a06bf1fa034476becb0882f11225d5d37564b3cf94eb
"
"sha256": "
52896a42e739f955a7fd50d6862a302027daa0487f341972373c0935e0a0b2aa
"
},
"pipfile-spec": 6,
"requires": {
...
...
@@ -24,6 +24,14 @@
"index": "pypi",
"version": "==2.2.1"
},
"django-ace": {
"hashes": [
"sha256:1334f08b4c5548e8ab13b25787e6a3f49dfe5fc92bb3a3d845b5b42fa0e1aff6",
"sha256:a2616b0265bdc1f839cc905c77243f779d82c00f3fddf58d23c08eb07e91e189"
],
"index": "pypi",
"version": "==1.0.5"
},
"django-bootstrap4": {
"hashes": [
"sha256:9f115534ae8d052d397201f3d716c10d7c9832b422e44dd7382418c6f274df18"
...
...
aspava/settings.py
Dosyayı görüntüle @
eb75f115
...
...
@@ -38,7 +38,8 @@ INSTALLED_APPS = [
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'social'
,
'bootstrap4'
'bootstrap4'
,
'django_ace'
]
MIDDLEWARE
=
[
...
...
social/forms.py
Dosyayı görüntüle @
eb75f115
from
django
import
forms
from
django.contrib.auth.forms
import
UserChangeForm
,
UserCreationForm
from
django.contrib.auth
import
get_user_model
from
django_ace
import
AceWidget
from
social.models
import
Post
,
Link
,
Snippet
...
...
@@ -24,6 +25,9 @@ class SnippetCreationForm(forms.ModelForm):
class
Meta
:
model
=
Snippet
fields
=
(
"text"
,)
widgets
=
{
"text"
:
AceWidget
(
mode
=
'python'
,
theme
=
'monokai'
),
}
class
LinkCreationForm
(
forms
.
ModelForm
):
class
Meta
:
...
...
social/templates/base.html
Dosyayı görüntüle @
eb75f115
...
...
@@ -16,7 +16,7 @@
<body>
<nav
class=
"navbar navbar-expand-md navbar-dark bg-dark fixed-top"
>
<a
class=
"navbar-brand"
href=
"
#
"
>
Aspava
</a>
<a
class=
"navbar-brand"
href=
"
{% url 'home' %}
"
>
Aspava
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarsExampleDefault"
aria-controls=
"navbarsExampleDefault"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
...
...
social/templates/forms/snippet.html
Dosyayı görüntüle @
eb75f115
{% extends 'base.html' %}
{% block title %}Post snippet{% endblock %}
{% block css %}{{ form.media }}{% endblock %}
{% block content %}
{% load bootstrap4 %}
...
...
social/views.py
Dosyayı görüntüle @
eb75f115
...
...
@@ -7,6 +7,7 @@ from purima.views import ExtendedListView
from
social
import
forms
from
social.models
import
Link
,
Post
,
Snippet
class
Home
(
ExtendedListView
):
models
=
Post
,
Snippet
,
Link
template_name
=
"home.html"
...
...
@@ -14,8 +15,8 @@ class Home(ExtendedListView):
def
get_queryset
(
self
):
qs
=
list
(
super
()
.
get_queryset
())
qs
.
sort
(
key
=
(
lambda
item
:
item
.
pub_date
))
return
qs
qs
.
sort
(
key
=
(
lambda
item
:
item
.
id
))
return
reversed
(
qs
)
class
Register
(
CreateView
):
...
...
@@ -33,7 +34,18 @@ class SharableCreate(CreateView):
def
form_valid
(
self
,
form
):
form
.
instance
.
author
=
self
.
request
.
user
return
super
()
.
form_valid
(
form
)
class
SharableCreate
(
CreateView
):
def
__init_subclass__
(
cls
):
cls
.
form_class
=
getattr
(
forms
,
f
"{cls.__name__}CreationForm"
)
cls
.
success_url
=
reverse_lazy
(
"home"
)
cls
.
template_name
=
f
"forms/{cls.__name__.lower()}.html"
super
()
.
__init_subclass__
()
def
form_valid
(
self
,
form
):
form
.
instance
.
author
=
self
.
request
.
user
return
super
()
.
form_valid
(
form
)
class
Post
(
SharableCreate
):
pass
...
...
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