Esempio n. 1
0
 def clean_show_name(self):
     show_name = self.cleaned_data.get('show_name')
     if not get_show_details(show_name):
         raise ValidationError("TV Show Not Found")
     elif get_show_details(show_name).status == 'Ended':
         raise ValidationError("TV Show Has Ended")
     return show_name
Esempio n. 2
0
def reminder(request):
	if request.method == 'POST':
		form = SubscriptionForm(request.POST)

		if form.is_valid():
			instance = form.save(commit = False)
			form_show = form.cleaned_data.get("show_name")
			print(form_show)
			tv_show = get_show_details(form_show)

			instance.show_id = tv_show.tv_show_id
			instance.show_name = tv_show.name
			print(tv_show.air_date)
			if tv_show.air_date != None:
				instance.show_date, instance.show_time = tv_show.air_date.split("T")
			#instance.show_date = datetime.datetime.strptime(instance.air_date, '%Y-%m-%d').date()
			
			
			#instance.timestamp = tv_show.air_date
			instance.save()
			return show_details(request, instance)
		else:
			print(form.errors)
	else:
		form = SubscriptionForm()

	title = 'Welcome'
	#subscription_list= Subscription.objects.all()
	#print(subscription_list)

	context = {
		"title": title,
		#"subscriptions": subscription_list,
		"form": form
	}
	return render(request, "home.html", context)