def test_registration_form(self): # test invalid data invalid_data = { "username": "******", "password": "******", "confirm": "not secret" } form = CourseEnrollForm(data=invalid_data) form.is_valid() self.assertTrue(form.errors)
def get_context_data(self, **kwargs): """ include the enrollment form in the context for rendering the templates """ context = super(CourseDetailView,self).get_context_data(**kwargs) # initialize the hiddencourse field of the form with the current `Course` object # s.t. it can submitted directly context['enroll_form'] = CourseEnrollForm(initial={'course':self.object}) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['lastest'] = self.model.objects.order_by('-created').exclude( id=self.get_object().id)[:6] context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial = {'course':self.object}) return context
def get_context_data(self, **kwargs): # Include the enrollment form in the context # for rendering the templates. context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) context['review_form'] = ReviewForm() context['reviews'] = Review.objects.order_by('-pub_date')[:9] return context
def get_context_data(self, **kwargs): '''method that includes enrollment form in teh context for rendering templates ''' context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): """get_context_data() method to include the enrollment form in the context for rendering the templates""" context = super().get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): """ do umieszczenia formularza zapisu na kurs w kontekście dla generowanego szablonu. """ context = super(CourseDetailView,self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm(initial={'course' : self.object}) return context
def get_context_data(self, **kwargs): context = super(CourseDetailView, self).get_context_data(**kwargs) course = self.get_object() context['enroll_form'] = CourseEnrollForm( initial={'course':self.object}) context['cart_product_form'] = CartAddProductForm( initial={'course':self.object}) context['modules'] = course.modules.all() return context
def get_context_data(self, **kwargs): #the method is used in order to render the #enrollement form so while the course detail #is rendered the enrollement form is rendered #also context = super().get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): """ Добавляем форму в контекст шаблона. Для записи пользователя на данный курс Объект формы содержит скрытое поле с ID курса, поэтому при нажатии кнопки на сервер будут отправлены данные курса и пользователя. """ context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm(initial={'course': self.object}) return context
def get_context_data(self, **kwargs): '''We use the get_context_data() method to include the enrollment form in the context for rendering the templates. We initialize the hidden course field of the form with the current Course object, so that it can be submitted directly.''' context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): """ переопределяем, чтобы добавить форму в шаблон в форме содержится скрытое поле с id курса """ context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): """ Add the 'enroll' button (form, FFS) to the 'course-overview' page """ context = super(CourseDetailView, self).get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( # initialize the hidden course field of the form with the current Course object so that it can be submitted directly. initial={'course': self.object}) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["related_items"] = self.object.tags.similar_objects()[:4] context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) print(self.get_object().id) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) return context
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['enroll_form'] = CourseEnrollForm( initial={'course': self.object}) context['announcements'] = self.object.announcements.all() return context
def get_context_data(self, **kwargs): context_data = super().get_context_data(**kwargs) context_data["enroll_form"] = CourseEnrollForm( initial={"course": self.object}) return context_data