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
92a76242
Kaydet (Commit)
92a76242
authored
May 06, 2019
tarafından
Batuhan Taşkaya
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Posting functionality
üst
c49d49c8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
14 deletions
+36
-14
purima
purima
+1
-1
forms.py
social/forms.py
+6
-1
base.html
social/templates/base.html
+1
-1
post.html
social/templates/forms/post.html
+16
-0
urls.py
social/urls.py
+2
-1
views.py
social/views.py
+10
-10
No files found.
purima
@
c60678ba
Subproject commit
b0a1904f280c0faf20dd6de5efb0ef35235b2b4a
Subproject commit
c60678baf7b1cf3d16af0002ced05ee1b9763e08
social/forms.py
Dosyayı görüntüle @
92a76242
...
...
@@ -2,7 +2,7 @@ from django import forms
from
django.contrib.auth.forms
import
UserChangeForm
,
UserCreationForm
from
django.contrib.auth
import
get_user_model
from
social.models
import
SocialUser
from
social.models
import
Post
class
SocialUserCreationForm
(
UserCreationForm
):
...
...
@@ -14,3 +14,8 @@ class SocialUserChangeForm(UserChangeForm):
class
Meta
:
model
=
get_user_model
()
fields
=
(
"username"
,
"email"
,
"avatar"
)
class
PostCreationForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Post
fields
=
(
"text"
,)
social/templates/base.html
Dosyayı görüntüle @
92a76242
...
...
@@ -28,7 +28,7 @@
</li>
{% if user.is_authenticated %}
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"
#
"
>
Post
</a>
<a
class=
"nav-link"
href=
"
{% url 'post' %}
"
>
Post
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'logout' %}"
>
Logout
</a>
...
...
social/templates/forms/post.html
0 → 100644
Dosyayı görüntüle @
92a76242
{% extends 'base.html' %}
{% block title %}Post{% endblock %}
{% block content %}
{% load bootstrap4 %}
<h2>
Post to feed
</h2>
<form
action=
"{% url 'post' %}"
method=
"post"
class=
"form"
>
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button
type=
"submit"
class=
"btn btn-primary"
>
Post
</button>
{% endbuttons %}
</form>
{% endblock %}
social/urls.py
Dosyayı görüntüle @
92a76242
...
...
@@ -5,11 +5,12 @@ from typing import Optional, Sequence
from
django.urls
import
include
,
path
from
purima.urls
import
PatternManager
,
IncludeFilter
from
social.views
import
Home
,
Profile
,
Register
from
social.views
import
Home
,
Profile
,
Register
,
Post
class
SocialPatterns
(
PatternManager
):
home
=
""
,
Home
post
=
"post/"
,
Post
profile
=
"people/<slug>/"
,
Profile
register
=
"accounts/register/"
,
Register
...
...
social/views.py
Dosyayı görüntüle @
92a76242
from
itertools
import
chain
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.models
import
Link
,
Post
,
Snippet
from
social.forms
import
SocialUserCreationForm
class
ExtendedListView
(
ListView
):
def
get_queryset
(
self
):
return
chain
.
from_iterable
(
map
(
lambda
model
:
model
.
_default_manager
.
all
(),
self
.
models
)
)
from
social.forms
import
PostCreationForm
,
SocialUserCreationForm
class
Home
(
ExtendedListView
):
models
=
Post
,
Snippet
,
Link
...
...
@@ -32,7 +24,15 @@ class Register(CreateView):
success_url
=
reverse_lazy
(
"login"
)
template_name
=
"registration/register.html"
class
Post
(
CreateView
):
form_class
=
PostCreationForm
success_url
=
reverse_lazy
(
"home"
)
template_name
=
"forms/post.html"
def
form_valid
(
self
,
form
):
form
.
instance
.
author
=
self
.
request
.
user
return
super
()
.
form_valid
(
form
)
class
Profile
(
DetailView
):
model
=
get_user_model
()
slug_field
=
"username"
...
...
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