Adding the template structure links, improving the model and defining… · pythonDrive/bootcamp@e4a4207 · GitHub
Skip to content

Commit e4a4207

Browse files
Adding the template structure links, improving the model and defining some parts of the view.
1 parent 08ee57b commit e4a4207

5 files changed

Lines changed: 9 additions & 14 deletions

File tree

bootcamp/qa/forms.py

Lines changed: 1 addition & 1 deletion

bootcamp/qa/models.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ class Meta:
127127
verbose_name = _("Answer")
128128
verbose_name_plural = _("Answers")
129129

130-
def save(self, *args, **kwargs):
131-
if not self.slug:
132-
self.slug = slugify(f"{self.title}-{self.uuid_id}",
133-
to_lower=True, max_length=80)
134-
135-
super().save(*args, **kwargs)
136-
137130
def __str__(self): # pragma: no cover
138131
return self.content
139132

bootcamp/qa/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
views.QuestionDetailView.as_view(), name='question_detail'),
1010
url(r'^answer-detail/(?P<uuid_id>\d+)/$',
1111
views.AnswerDetailView.as_view(), name='answer_detail'),
12-
url(r'^new-question/$', views.CreateQuestionView.as_view(),
13-
name='create_question'),
14-
url(r'^create-answer/(?P<question_id>\d+)/$',
15-
views.CreateAnswerView.as_view(), name='create_answer'),
12+
url(r'^ask-question/$', views.CreateQuestionView.as_view(),
13+
name='ask_question'),
14+
url(r'^propose-answer/(?P<question_id>\d+)/$',
15+
views.CreateAnswerView.as_view(), name='propose_answer'),
1616
]

bootcamp/qa/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class QuestionListView(LoginRequiredMixin, ListView):
1919

2020
class AnswerListView(LoginRequiredMixin, ListView):
2121
model = Answer
22-
paginate_by = 20
22+
paginate_by = 5
2323
context_object_name = "answers"
2424

2525

@@ -42,6 +42,7 @@ class CreateQuestionView(LoginRequiredMixin, CreateView):
4242
View to handle the creation of a new question
4343
"""
4444
model = Question
45+
fields = ["title", "content", "tags", "status"]
4546
message = _('Your question has been created.')
4647

4748
def form_valid(self, form):
@@ -58,6 +59,7 @@ class CreateAnswerView(LoginRequiredMixin, CreateView):
5859
View to create new answers for a given question
5960
"""
6061
model = Answer
62+
fields = ["question", "description"]
6163
message = _('Thank you! Your answer has been posted.')
6264

6365
def form_valid(self, form):

bootcamp/templates/base.html

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)