forked from arjunkomath/Simple-Q-A-App-using-Python-Django
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with the refactoring of user and user profile model
- Loading branch information
Cristian Vargas
committed
Mar 17, 2016
1 parent
943ea72
commit aae8349
Showing
2 changed files
with
15 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,29 +115,26 @@ def add(request): | |
question_text = request.POST['question'] | ||
tags_text = request.POST['tags'] | ||
user_id = request.POST['user'] | ||
user_ob = get_user_model().objects.get(id=user_id) | ||
user = user_ob.userqaprofile | ||
user = get_user_model().objects.get(id=user_id) | ||
|
||
if question_text.strip() == '': | ||
return render(request, 'qa/add.html', {'message': 'Empty'}) | ||
|
||
pub_date = datetime.datetime.now() | ||
q = Question() | ||
q.question_text = question_text | ||
q.pub_date = pub_date | ||
q.user_data = user | ||
q.save() | ||
question = Question() | ||
question.question_text = question_text | ||
question.user = user | ||
question.save() | ||
|
||
tags = tags_text.split(',') | ||
for tag in tags: | ||
try: | ||
t = Tag.objects.get(slug=tag) | ||
q.tags.add(t) | ||
tag = Tag.objects.get(slug=tag) | ||
question.tags.add(tag) | ||
except Tag.DoesNotExist: | ||
t=Tag() | ||
t.slug = tag | ||
t.save() | ||
q.tags.add(t) | ||
tag = Tag() | ||
tag.slug = tag | ||
tag.save() | ||
question.tags.add(tag) | ||
|
||
#send_mail('QA: Your Question has been Posted.', 'Thank you for posting the question, '+question_text+'. We will notify you once someone posts an answer.', '[email protected]', [request.user.email], fail_silently=False) | ||
|
||
|