Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jean Michel Rouly
research-questions
Commits
48c86f0d
Commit
48c86f0d
authored
Dec 04, 2013
by
Jean Michel Rouly
Browse files
Process comment form.
parent
4e32cd40
Changes
2
Hide whitespace changes
Inline
Side-by-side
researchquestions/templates/question.html
View file @
48c86f0d
...
...
@@ -15,6 +15,18 @@ HNRS 110 • Question Discussion
</div>
</div>
{% if comment_form.errors %}
<div
class=
"row"
>
<div
class=
"col-lg-10 col-lg-offset-1"
>
<div
class=
"alert alert-dismissable alert-danger"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
>
×
</button>
<strong>
Oh snap!
</strong>
There was an error posting your comment.
Please try again.
</div>
</div>
</div>
{% endif %}
<div
class=
"row"
>
<div
class=
"col-lg-10 col-lg-offset-1"
>
<div
class=
"panel panel-primary"
>
...
...
@@ -38,9 +50,7 @@ HNRS 110 • Question Discussion
Make Comment
</a>
<div
class=
"collapse"
id=
"make-comment"
>
Form
</div>
{% include 'comment_form.html' %}
</div>
</div>
...
...
researchquestions/website/views.py
View file @
48c86f0d
...
...
@@ -8,7 +8,9 @@ from django.contrib.auth.models import User
from
django.template
import
RequestContext
from
django.http
import
HttpResponseRedirect
from
django.core.mail
import
EmailMessage
from
django.utils
import
timezone
import
os
import
requests
# Create your views here.
...
...
@@ -50,7 +52,12 @@ def feedback(request):
if
request
.
method
==
'POST'
:
form
=
FeedbackForm
(
request
.
POST
)
if
form
.
is_valid
():
# email me
f
=
open
(
os
.
path
.
join
(
settings
.
MEDIA_ROOT
,
'feedback.txt'
),
'a'
)
data
=
form
.
cleaned_data
f
.
write
(
str
(
timezone
.
now
())
)
f
.
write
(
str
(
'
\n
'
)
)
f
.
write
(
data
[
'text'
]
)
f
.
write
(
str
(
'
\n\n\n
'
)
)
return
HttpResponseRedirect
(
'/'
)
else
:
form
=
FeedbackForm
()
...
...
@@ -62,8 +69,20 @@ def feedback(request):
)
def
view_question
(
request
,
slug
):
if
request
.
method
==
'POST'
:
comment_form
=
CommentForm
(
request
.
POST
)
if
comment_form
.
is_valid
():
comment
=
comment_form
.
save
(
commit
=
False
)
comment
.
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
comment
.
parent
=
Question
.
objects
.
get
(
id
=
slug
)
comment
.
save
()
return
HttpResponseRedirect
(
''
)
else
:
comment_form
=
CommentForm
()
return
render_to_response
(
'question.html'
,
{
'question'
:
get_object_or_404
(
Question
,
pk
=
slug
),
'comment_form'
:
comment_form
,
},
RequestContext
(
request
),
)
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