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
dbaf6bbc
Kaydet (Commit)
dbaf6bbc
authored
May 08, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Full CRUD
üst
710ed9f5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
88 additions
and
3 deletions
+88
-3
link.html
social/templates/forms/update/link.html
+16
-0
post.html
social/templates/forms/update/post.html
+16
-0
snippet.html
social/templates/forms/update/snippet.html
+16
-0
home.html
social/templates/home.html
+2
-1
renderer.py
social/templatetags/renderer.py
+2
-2
urls.py
social/urls.py
+3
-0
update.py
social/views/crud/update.py
+33
-0
No files found.
social/templates/forms/update/link.html
0 → 100644
Dosyayı görüntüle @
dbaf6bbc
{% extends 'base.html' %}
{% block title %}Update link{% endblock %}
{% block content %}
{% load bootstrap4 %}
<h2>
Update Link
</h2>
<form
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button
type=
"submit"
class=
"btn btn-primary"
>
Update Link
</button>
{% endbuttons %}
</form>
{% endblock %}
social/templates/forms/update/post.html
0 → 100644
Dosyayı görüntüle @
dbaf6bbc
{% extends 'base.html' %}
{% block title %}Update post{% endblock %}
{% block content %}
{% load bootstrap4 %}
<h2>
Update Post
</h2>
<form
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button
type=
"submit"
class=
"btn btn-primary"
>
Update Post
</button>
{% endbuttons %}
</form>
{% endblock %}
social/templates/forms/update/snippet.html
0 → 100644
Dosyayı görüntüle @
dbaf6bbc
{% extends 'base.html' %}
{% block title %}Update snippet{% endblock %}
{% block css %}{{ form.media }}{% endblock %}
{% block content %}
{% load bootstrap4 %}
<h2>
Update Snippet
</h2>
<form
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button
type=
"submit"
class=
"btn btn-primary"
>
Update Snippet
</button>
{% endbuttons %}
</form>
{% endblock %}
social/templates/home.html
Dosyayı görüntüle @
dbaf6bbc
...
...
@@ -14,7 +14,8 @@
{% as_html item %}
<small
class=
"text-muted"
>
{{ item.pub_date }}
</small>
{% if item.author == request.user %}
<small
class=
"text-muted"
><a
href=
"{% get_delete item %}"
>
delete
</a></small>
<small
class=
"text-muted"
><a
href=
"{% get_opt 'delete' item %}"
>
delete
</a></small>
<small
class=
"text-muted"
><a
href=
"{% get_opt 'update' item %}"
>
update
</a></small>
{% endif %}
</fieldset>
</div>
...
...
social/templatetags/renderer.py
Dosyayı görüntüle @
dbaf6bbc
...
...
@@ -35,5 +35,5 @@ def get_preview(url):
return
preview
@register.simple_tag
def
get_
delete
(
item
):
return
reverse
(
f
"
delete
_{_get_class(item)}"
,
args
=
(
item
.
id
,))
def
get_
opt
(
opt
,
item
):
return
reverse
(
f
"
{opt}
_{_get_class(item)}"
,
args
=
(
item
.
id
,))
social/urls.py
Dosyayı görüntüle @
dbaf6bbc
...
...
@@ -22,12 +22,15 @@ class SocialPatterns(PatternManager):
class
SocialPostPatterns
(
PatternManager
):
create_post
=
"post/create"
,
CreatePost
update_post
=
"post/update/<int:pk>"
,
UpdatePost
delete_post
=
"post/delete/<int:pk>"
,
DeletePost
create_link
=
"link/create"
,
CreateLink
update_link
=
"link/update/<int:pk>"
,
UpdateLink
delete_link
=
"link/delete/<int:pk>"
,
DeleteLink
create_snippet
=
"snippet/create"
,
CreateSnippet
update_snippet
=
"snippet/update/<int:pk>"
,
UpdateSnippet
delete_snippet
=
"snippet/delete/<int:pk>"
,
DeleteSnippet
urlpatterns
=
SocialPatterns
()
+
SocialPostPatterns
()
...
...
social/views/crud/update.py
Dosyayı görüntüle @
dbaf6bbc
from
django.urls
import
reverse_lazy
from
django.views.generic
import
UpdateView
from
django.http
import
HttpResponse
from
social
import
models
,
forms
__all__
=
[
'UpdatePost'
,
'UpdateLink'
,
'UpdateSnippet'
]
class
SharableUpdate
(
UpdateView
):
def
__init_subclass__
(
cls
):
simple_name
=
cls
.
__name__
.
replace
(
'Update'
,
''
)
.
lower
()
cls
.
model
=
getattr
(
models
,
f
"{simple_name.title()}"
)
cls
.
success_url
=
reverse_lazy
(
"home"
)
cls
.
template_name
=
f
"forms/update/{simple_name}.html"
cls
.
form_class
=
getattr
(
forms
,
f
"Create{simple_name.title()}Form"
)
super
()
.
__init_subclass__
()
def
form_valid
(
self
,
*
args
,
**
kwargs
):
if
self
.
get_object
()
.
author
==
self
.
request
.
user
:
return
super
()
.
form_valid
(
*
args
,
**
kwargs
)
else
:
return
HttpResponse
(
'Unauthorized'
,
status
=
401
)
class
UpdatePost
(
SharableUpdate
):
pass
class
UpdateLink
(
SharableUpdate
):
pass
class
UpdateSnippet
(
SharableUpdate
):
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