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
bd0d2ed6
Kaydet (Commit)
bd0d2ed6
authored
May 06, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Adapting CRUD system
üst
eb75f115
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
77 additions
and
77 deletions
+77
-77
forms.py
social/forms.py
+3
-3
base.html
social/templates/base.html
+3
-3
link.html
social/templates/forms/create/link.html
+1
-1
post.html
social/templates/forms/create/post.html
+1
-1
snippet.html
social/templates/forms/create/snippet.html
+1
-1
renderer.py
social/templatetags/renderer.py
+1
-1
urls.py
social/urls.py
+7
-5
views.py
social/views.py
+0
-62
__init__.py
social/views/__init__.py
+15
-0
auth.py
social/views/auth.py
+17
-0
__init__.py
social/views/crud/__init__.py
+3
-0
create.py
social/views/crud/create.py
+25
-0
delete.py
social/views/crud/delete.py
+0
-0
update.py
social/views/crud/update.py
+0
-0
No files found.
social/forms.py
Dosyayı görüntüle @
bd0d2ed6
...
...
@@ -16,12 +16,12 @@ class SocialUserChangeForm(UserChangeForm):
model
=
get_user_model
()
fields
=
(
"username"
,
"email"
,
"avatar"
)
class
PostCreation
Form
(
forms
.
ModelForm
):
class
CreatePost
Form
(
forms
.
ModelForm
):
class
Meta
:
model
=
Post
fields
=
(
"text"
,)
class
SnippetCreation
Form
(
forms
.
ModelForm
):
class
CreateSnippet
Form
(
forms
.
ModelForm
):
class
Meta
:
model
=
Snippet
fields
=
(
"text"
,)
...
...
@@ -29,7 +29,7 @@ class SnippetCreationForm(forms.ModelForm):
"text"
:
AceWidget
(
mode
=
'python'
,
theme
=
'monokai'
),
}
class
LinkCreation
Form
(
forms
.
ModelForm
):
class
CreateLink
Form
(
forms
.
ModelForm
):
class
Meta
:
model
=
Link
fields
=
(
"url"
,)
social/templates/base.html
Dosyayı görüntüle @
bd0d2ed6
...
...
@@ -28,13 +28,13 @@
</li>
{% if user.is_authenticated %}
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'post' %}"
>
Post
</a>
<a
class=
"nav-link"
href=
"{% url '
create_
post' %}"
>
Post
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'link' %}"
>
Link
</a>
<a
class=
"nav-link"
href=
"{% url '
create_
link' %}"
>
Link
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'snippet' %}"
>
Snippet
</a>
<a
class=
"nav-link"
href=
"{% url '
create_
snippet' %}"
>
Snippet
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'logout' %}"
>
Logout
</a>
...
...
social/templates/forms/link.html
→
social/templates/forms/
create/
link.html
Dosyayı görüntüle @
bd0d2ed6
...
...
@@ -6,7 +6,7 @@
{% block content %}
{% load bootstrap4 %}
<h2>
Post link to feed
</h2>
<form
action=
"{% url 'link' %}"
method=
"post"
class=
"form"
>
<form
action=
"{% url '
create_
link' %}"
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
...
...
social/templates/forms/post.html
→
social/templates/forms/
create/
post.html
Dosyayı görüntüle @
bd0d2ed6
...
...
@@ -6,7 +6,7 @@
{% block content %}
{% load bootstrap4 %}
<h2>
Post to feed
</h2>
<form
action=
"{% url 'post' %}"
method=
"post"
class=
"form"
>
<form
action=
"{% url '
create_
post' %}"
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
...
...
social/templates/forms/snippet.html
→
social/templates/forms/
create/
snippet.html
Dosyayı görüntüle @
bd0d2ed6
...
...
@@ -6,7 +6,7 @@
{% block content %}
{% load bootstrap4 %}
<h2>
Post snippet to feed
</h2>
<form
action=
"{% url 'snippet' %}"
method=
"post"
class=
"form"
>
<form
action=
"{% url '
create_
snippet' %}"
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
...
...
social/templatetags/renderer.py
Dosyayı görüntüle @
bd0d2ed6
...
...
@@ -2,7 +2,7 @@ from urllib.parse import urlparse
from
django
import
template
from
django.template.loader
import
render_to_string
from
purima.utils.get_preview
import
get_preview
as
_get_preview
from
purima.utils.get_preview
import
_get_preview
register
=
template
.
Library
()
...
...
social/urls.py
Dosyayı görüntüle @
bd0d2ed6
...
...
@@ -5,14 +5,11 @@ from typing import Optional, Sequence
from
django.urls
import
include
,
path
from
purima.urls
import
PatternManager
,
IncludeFilter
from
social.views
import
Home
,
Profile
,
Register
,
Post
,
Link
,
Snippet
from
social.views
import
*
class
SocialPatterns
(
PatternManager
):
home
=
""
,
Home
post
=
"share/post/"
,
Post
link
=
"share/link/"
,
Link
snippet
=
"share/snippet/"
,
Snippet
profile
=
"people/<slug>/"
,
Profile
register
=
"accounts/register/"
,
Register
...
...
@@ -22,5 +19,10 @@ class SocialPatterns(PatternManager):
)
}
urlpatterns
=
SocialPatterns
()
class
SocialPostPatterns
(
PatternManager
):
create_post
=
"create/post"
,
CreatePost
create_link
=
"create/link"
,
CreateLink
create_snippet
=
"create/snippet"
,
CreateSnippet
urlpatterns
=
SocialPatterns
()
+
SocialPostPatterns
()
social/views.py
deleted
100755 → 0
Dosyayı görüntüle @
eb75f115
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.forms
import
UserCreationForm
from
django.urls
import
reverse_lazy
from
django.views.generic
import
CreateView
,
DetailView
,
ListView
from
django.views.generic.base
import
TemplateView
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"
context_object_name
=
"feed"
def
get_queryset
(
self
):
qs
=
list
(
super
()
.
get_queryset
())
qs
.
sort
(
key
=
(
lambda
item
:
item
.
id
))
return
reversed
(
qs
)
class
Register
(
CreateView
):
form_class
=
forms
.
SocialUserCreationForm
success_url
=
reverse_lazy
(
"login"
)
template_name
=
"registration/register.html"
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
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
class
Link
(
SharableCreate
):
pass
class
Snippet
(
SharableCreate
):
pass
class
Profile
(
DetailView
):
model
=
get_user_model
()
slug_field
=
"username"
template_name
=
"user/profile.html"
social/views/__init__.py
0 → 100644
Dosyayı görüntüle @
bd0d2ed6
from
social.views.crud
import
*
from
social.views.auth
import
*
from
purima.views
import
ExtendedListView
from
social.models
import
Link
,
Post
,
Snippet
class
Home
(
ExtendedListView
):
models
=
Post
,
Snippet
,
Link
template_name
=
"home.html"
context_object_name
=
"feed"
def
get_queryset
(
self
):
qs
=
list
(
super
()
.
get_queryset
())
qs
.
sort
(
key
=
(
lambda
item
:
item
.
id
))
return
reversed
(
qs
)
social/views/auth.py
0 → 100644
Dosyayı görüntüle @
bd0d2ed6
from
django.views.generic
import
CreateView
,
DetailView
from
django.urls
import
reverse_lazy
from
django.contrib.auth
import
get_user_model
from
social
import
forms
__all__
=
[
'Register'
,
'Profile'
]
class
Register
(
CreateView
):
form_class
=
forms
.
SocialUserCreationForm
success_url
=
reverse_lazy
(
"login"
)
template_name
=
"registration/register.html"
class
Profile
(
DetailView
):
model
=
get_user_model
()
slug_field
=
"username"
template_name
=
"user/profile.html"
social/views/crud/__init__.py
0 → 100644
Dosyayı görüntüle @
bd0d2ed6
from
social.views.crud.create
import
*
from
social.views.crud.update
import
*
from
social.views.crud.delete
import
*
social/views/crud/create.py
0 → 100644
Dosyayı görüntüle @
bd0d2ed6
from
django.urls
import
reverse_lazy
from
django.views.generic
import
CreateView
from
social
import
forms
__all__
=
[
'CreatePost'
,
'CreateLink'
,
'CreateSnippet'
]
class
SharableCreate
(
CreateView
):
def
__init_subclass__
(
cls
):
cls
.
form_class
=
getattr
(
forms
,
f
"{cls.__name__}Form"
)
cls
.
success_url
=
reverse_lazy
(
"home"
)
cls
.
template_name
=
f
"forms/create/{cls.__name__.replace('Create', '').lower()}.html"
super
()
.
__init_subclass__
()
def
form_valid
(
self
,
form
):
form
.
instance
.
author
=
self
.
request
.
user
return
super
()
.
form_valid
(
form
)
class
CreatePost
(
SharableCreate
):
pass
class
CreateLink
(
SharableCreate
):
pass
class
CreateSnippet
(
SharableCreate
):
pass
social/views/crud/delete.py
0 → 100644
Dosyayı görüntüle @
bd0d2ed6
social/views/crud/update.py
0 → 100644
Dosyayı görüntüle @
bd0d2ed6
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