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
a013b202
Kaydet (Commit)
a013b202
authored
May 06, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Sharable snippets and links
üst
92a76242
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
12 deletions
+73
-12
forms.py
social/forms.py
+11
-1
base.html
social/templates/base.html
+6
-0
link.html
social/templates/forms/link.html
+16
-0
snippet.html
social/templates/forms/snippet.html
+16
-0
urls.py
social/urls.py
+5
-3
views.py
social/views.py
+19
-8
No files found.
social/forms.py
Dosyayı görüntüle @
a013b202
...
@@ -2,7 +2,7 @@ from django import forms
...
@@ -2,7 +2,7 @@ from django import forms
from
django.contrib.auth.forms
import
UserChangeForm
,
UserCreationForm
from
django.contrib.auth.forms
import
UserChangeForm
,
UserCreationForm
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth
import
get_user_model
from
social.models
import
Post
from
social.models
import
Post
,
Link
,
Snippet
class
SocialUserCreationForm
(
UserCreationForm
):
class
SocialUserCreationForm
(
UserCreationForm
):
...
@@ -19,3 +19,13 @@ class PostCreationForm(forms.ModelForm):
...
@@ -19,3 +19,13 @@ class PostCreationForm(forms.ModelForm):
class
Meta
:
class
Meta
:
model
=
Post
model
=
Post
fields
=
(
"text"
,)
fields
=
(
"text"
,)
class
SnippetCreationForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Snippet
fields
=
(
"text"
,)
class
LinkCreationForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Link
fields
=
(
"url"
,)
social/templates/base.html
Dosyayı görüntüle @
a013b202
...
@@ -30,6 +30,12 @@
...
@@ -30,6 +30,12 @@
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'post' %}"
>
Post
</a>
<a
class=
"nav-link"
href=
"{% url 'post' %}"
>
Post
</a>
</li>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'link' %}"
>
Link
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'snippet' %}"
>
Snippet
</a>
</li>
<li
class=
"nav-item"
>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'logout' %}"
>
Logout
</a>
<a
class=
"nav-link"
href=
"{% url 'logout' %}"
>
Logout
</a>
</li>
</li>
...
...
social/templates/forms/link.html
0 → 100644
Dosyayı görüntüle @
a013b202
{% extends 'base.html' %}
{% block title %}Post link{% endblock %}
{% block content %}
{% load bootstrap4 %}
<h2>
Post link to feed
</h2>
<form
action=
"{% url 'link' %}"
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button
type=
"submit"
class=
"btn btn-primary"
>
Post link
</button>
{% endbuttons %}
</form>
{% endblock %}
social/templates/forms/snippet.html
0 → 100644
Dosyayı görüntüle @
a013b202
{% extends 'base.html' %}
{% block title %}Post snippet{% endblock %}
{% block content %}
{% load bootstrap4 %}
<h2>
Post snippet to feed
</h2>
<form
action=
"{% url 'snippet' %}"
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button
type=
"submit"
class=
"btn btn-primary"
>
Post snippet
</button>
{% endbuttons %}
</form>
{% endblock %}
social/urls.py
Dosyayı görüntüle @
a013b202
...
@@ -5,15 +5,17 @@ from typing import Optional, Sequence
...
@@ -5,15 +5,17 @@ from typing import Optional, Sequence
from
django.urls
import
include
,
path
from
django.urls
import
include
,
path
from
purima.urls
import
PatternManager
,
IncludeFilter
from
purima.urls
import
PatternManager
,
IncludeFilter
from
social.views
import
Home
,
Profile
,
Register
,
Post
from
social.views
import
Home
,
Profile
,
Register
,
Post
,
Link
,
Snippet
class
SocialPatterns
(
PatternManager
):
class
SocialPatterns
(
PatternManager
):
home
=
""
,
Home
home
=
""
,
Home
post
=
"post/"
,
Post
post
=
"share/post/"
,
Post
link
=
"share/link/"
,
Link
snippet
=
"share/snippet/"
,
Snippet
profile
=
"people/<slug>/"
,
Profile
profile
=
"people/<slug>/"
,
Profile
register
=
"accounts/register/"
,
Register
register
=
"accounts/register/"
,
Register
includes
=
{
includes
=
{
"accounts/"
:
IncludeFilter
(
"accounts/"
:
IncludeFilter
(
"django.contrib.auth.urls"
,
whitelist
=
(
"login"
,
"logout"
)
"django.contrib.auth.urls"
,
whitelist
=
(
"login"
,
"logout"
)
...
...
social/views.py
Dosyayı görüntüle @
a013b202
...
@@ -5,9 +5,8 @@ from django.views.generic import CreateView, DetailView, ListView
...
@@ -5,9 +5,8 @@ from django.views.generic import CreateView, DetailView, ListView
from
django.views.generic.base
import
TemplateView
from
django.views.generic.base
import
TemplateView
from
purima.views
import
ExtendedListView
from
purima.views
import
ExtendedListView
from
social
import
forms
from
social.models
import
Link
,
Post
,
Snippet
from
social.models
import
Link
,
Post
,
Snippet
from
social.forms
import
PostCreationForm
,
SocialUserCreationForm
class
Home
(
ExtendedListView
):
class
Home
(
ExtendedListView
):
models
=
Post
,
Snippet
,
Link
models
=
Post
,
Snippet
,
Link
template_name
=
"home.html"
template_name
=
"home.html"
...
@@ -20,18 +19,30 @@ class Home(ExtendedListView):
...
@@ -20,18 +19,30 @@ class Home(ExtendedListView):
class
Register
(
CreateView
):
class
Register
(
CreateView
):
form_class
=
SocialUserCreationForm
form_class
=
forms
.
SocialUserCreationForm
success_url
=
reverse_lazy
(
"login"
)
success_url
=
reverse_lazy
(
"login"
)
template_name
=
"registration/register.html"
template_name
=
"registration/register.html"
class
Post
(
CreateView
):
class
SharableCreate
(
CreateView
):
form_class
=
PostCreationForm
def
__init_subclass__
(
cls
):
success_url
=
reverse_lazy
(
"home"
)
cls
.
form_class
=
getattr
(
forms
,
f
"{cls.__name__}CreationForm"
)
template_name
=
"forms/post.html"
cls
.
success_url
=
reverse_lazy
(
"home"
)
cls
.
template_name
=
f
"forms/{cls.__name__.lower()}.html"
super
()
.
__init_subclass__
()
def
form_valid
(
self
,
form
):
def
form_valid
(
self
,
form
):
form
.
instance
.
author
=
self
.
request
.
user
form
.
instance
.
author
=
self
.
request
.
user
return
super
()
.
form_valid
(
form
)
return
super
()
.
form_valid
(
form
)
class
Post
(
SharableCreate
):
pass
class
Link
(
SharableCreate
):
pass
class
Snippet
(
SharableCreate
):
pass
class
Profile
(
DetailView
):
class
Profile
(
DetailView
):
model
=
get_user_model
()
model
=
get_user_model
()
...
...
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