def serial(request, serial_title=None): show_id = request.GET.get('id') if id is None: s_title = strip(serial_title) obj = get_tv_show(TVSeries, s_title) if obj is None: return HttpResponse('/serialy/') #Check this else: obj = TVSeries.objects.get(id=show_id) ##CHECK THIS if request.user.is_authenticated(): today = date.today() profile = UserProfile.objects.get(user=request.user) if not profile.watched_series.filter(id=obj.id).exists(): profile.watched_series.add(obj) if not UserViewed.objects.filter(is_show=True).filter(obj_id=obj.id).filter(date__year=today.year).filter(date__month=today.month).filter(date__day=today.day).exists(): uvo = UserViewed(is_show=True,obj_id=obj.id,is_movie=False,is_episode=False,user=profile) uvo.save() else: #just a regular view v = View(view_count=1) v.save() obj.views.add(v) show_episodes = obj.episode_set.all().order_by('partOfSeason__number', 'episodeNumber') reviewed = UserMadeReview.objects.filter(is_show=True).filter(obj_id=show_id) des = obj.new_show.description img = obj.new_show.image title = obj.new_show.title number_of_ratings = obj.aggregate_rating.all().count() if number_of_ratings > 0: avg_rate = obj.aggregate_rating.all().aggregate(Avg('ratingValue')) if avg_rate['ratingValue__avg'] is not None: if type(avg_rate) is not int: avg_rate = int(avg_rate['ratingValue__avg']) else: avg_rate = 0 else: avg_rate = 0 if request.user.is_authenticated(): review_tip = 'napsat recenzi ' else: review_tip = 'pro tuto činnost se musíte registrovat' return render(request,'series/show2.html',{ 'obj': obj, 'the_title': title, 'the_image': img, 'the_description': des, 'show_episode_list_first': show_episodes, #'show_episode_list_second': s2, 'avg_rate': avg_rate, 'review_tip': review_tip, 'number_of_ratings': number_of_ratings, 'reviewed': reviewed })
def episode(request, serial_title=None, episode_title=None): e_id = request.GET.get('id') if e_id is not None: obj = Episode.objects.get(id=e_id) episode_link = obj.new_episode.link else: e_title = strip(episode_title) s_title = strip(serial_title) obj = get_episode(s_title, e_title) if obj is not None: try: episode_link = obj.new_episode.link except: episode_link = obj[0].new_episode.link else: return HttpResponseRedirect('/') if request.user.is_authenticated(): profile = UserProfile.objects.get(user=request.user) if not profile.watched_episodes.filter(id=obj.id).exists(): profile.watched_episodes.add(obj) if '<iframe' in episode_link[0:7]: frame = True else: frame = False number_of_episodes = obj.partOfSeries.episode_set.all().count() r = UserMadeReview.objects.filter(is_episode=True, obj_id=obj.id) if request.user.is_authenticated(): profile = UserProfile.objects.get(user=request.user) if not profile.watched_episodes.filter(id=obj.id).exists(): profile.watched_episodes.add(obj) v = View(view_count=1) v.save() obj.views.add(v) #avg_rate = obj.aggregate_rating.all().aggregate(Avg('ratingValue')) if EpisodeRating.objects.filter(episode=obj).exists(): avg_rate = EpisodeRating.objects.filter(episode=obj).aggregate(Avg('rating__ratingValue')) if avg_rate['rating__ratingValue__avg'] is not None: if type(avg_rate) is not int: avg_rate = int(avg_rate['rating__ratingValue__avg']) else: avg_rate = 0 else: avg_rate = 0 number_of_ratings = EpisodeRating.objects.filter(episode=obj) unique_ratings = [] go_count = 0 num = number_of_ratings.count() while go_count < num: current = number_of_ratings[go_count] print(current.user.username) if unique_ratings: already_in = False for rr in unique_ratings: #print('checking against %s' %current.user.username+' '+rr.user.username) if current.user.username == rr.user.username: already_in = True if already_in: pass else: #print('adding into %s'+current.user.username) unique_ratings.append(current) else: #print('added first') unique_ratings.append(current) go_count+=1 videoObj = EpisodeVideoObj.objects.filter(episode=obj).all() return render(request,'series/svideo.html',{ 'is_iframe': frame, 'the_episode_link': episode_link, 'episode': obj, 'numer_of_episodes': number_of_episodes, 'reviewed': r, 'avg_rate': avg_rate, 'number_of_ratings': unique_ratings, 'alt_videos':videoObj, })
def serial(request, serial_title=None): show_id = request.GET.get('id') if id is None: s_title = strip(serial_title) obj = get_tv_show(TVSeries, s_title) if obj is None: return HttpResponse('/serialy/') #Check this else: obj = TVSeries.objects.get(id=show_id) ##CHECK THIS if request.user.is_authenticated(): today = date.today() profile = UserProfile.objects.get(user=request.user) if not profile.watched_series.filter(id=obj.id).exists(): profile.watched_series.add(obj) if not UserViewed.objects.filter(is_show=True).filter( obj_id=obj.id).filter(date__year=today.year).filter( date__month=today.month).filter( date__day=today.day).exists(): uvo = UserViewed(is_show=True, obj_id=obj.id, is_movie=False, is_episode=False, user=profile) uvo.save() else: #just a regular view v = View(view_count=1) v.save() obj.views.add(v) show_episodes = obj.episode_set.all().order_by('partOfSeason__number', 'episodeNumber') reviewed = UserMadeReview.objects.filter(is_show=True).filter( obj_id=show_id) des = obj.new_show.description img = obj.new_show.image title = obj.new_show.title number_of_ratings = obj.aggregate_rating.all().count() if number_of_ratings > 0: avg_rate = obj.aggregate_rating.all().aggregate(Avg('ratingValue')) if avg_rate['ratingValue__avg'] is not None: if type(avg_rate) is not int: avg_rate = int(avg_rate['ratingValue__avg']) else: avg_rate = 0 else: avg_rate = 0 if request.user.is_authenticated(): review_tip = 'napsat recenzi ' else: review_tip = 'pro tuto činnost se musíte registrovat' return render( request, 'series/show2.html', { 'obj': obj, 'the_title': title, 'the_image': img, 'the_description': des, 'show_episode_list_first': show_episodes, #'show_episode_list_second': s2, 'avg_rate': avg_rate, 'review_tip': review_tip, 'number_of_ratings': number_of_ratings, 'reviewed': reviewed })
def episode(request, serial_title=None, episode_title=None): e_id = request.GET.get('id') if e_id is not None: obj = Episode.objects.get(id=e_id) episode_link = obj.new_episode.link else: e_title = strip(episode_title) s_title = strip(serial_title) obj = get_episode(s_title, e_title) if obj is not None: try: episode_link = obj.new_episode.link except: episode_link = obj[0].new_episode.link else: return HttpResponseRedirect('/') if request.user.is_authenticated(): profile = UserProfile.objects.get(user=request.user) if not profile.watched_episodes.filter(id=obj.id).exists(): profile.watched_episodes.add(obj) if '<iframe' in episode_link[0:7]: frame = True else: frame = False number_of_episodes = obj.partOfSeries.episode_set.all().count() r = UserMadeReview.objects.filter(is_episode=True, obj_id=obj.id) if request.user.is_authenticated(): profile = UserProfile.objects.get(user=request.user) if not profile.watched_episodes.filter(id=obj.id).exists(): profile.watched_episodes.add(obj) v = View(view_count=1) v.save() obj.views.add(v) #avg_rate = obj.aggregate_rating.all().aggregate(Avg('ratingValue')) if EpisodeRating.objects.filter(episode=obj).exists(): avg_rate = EpisodeRating.objects.filter(episode=obj).aggregate( Avg('rating__ratingValue')) if avg_rate['rating__ratingValue__avg'] is not None: if type(avg_rate) is not int: avg_rate = int(avg_rate['rating__ratingValue__avg']) else: avg_rate = 0 else: avg_rate = 0 number_of_ratings = EpisodeRating.objects.filter(episode=obj) unique_ratings = [] go_count = 0 num = number_of_ratings.count() while go_count < num: current = number_of_ratings[go_count] print(current.user.username) if unique_ratings: already_in = False for rr in unique_ratings: #print('checking against %s' %current.user.username+' '+rr.user.username) if current.user.username == rr.user.username: already_in = True if already_in: pass else: #print('adding into %s'+current.user.username) unique_ratings.append(current) else: #print('added first') unique_ratings.append(current) go_count += 1 videoObj = EpisodeVideoObj.objects.filter(episode=obj).all() return render( request, 'series/svideo.html', { 'is_iframe': frame, 'the_episode_link': episode_link, 'episode': obj, 'numer_of_episodes': number_of_episodes, 'reviewed': r, 'avg_rate': avg_rate, 'number_of_ratings': unique_ratings, 'alt_videos': videoObj, })
def film(request, movie_title=None, movie_id=None): tit = strip(movie_title) i_film = True sid = movie_id una = True if not sid: sid = request.GET.get('id') if not sid: try: the_film = Movie.objects.filter(name=tit).exclude(frame='None').exclude(frame__contains='filman.cz')[0] except Movie.DoesNotExist: return HttpResponseRedirect('/filmy/') else: the_film = Movie.objects.get(id=sid) else: the_film = Movie.objects.get(id=sid) if request.user.is_authenticated(): profile = UserProfile.objects.get(user=request.user) review_tip = 'napsat recenze' una = False if not profile.watched_movies.filter(id=the_film.id).exists(): profile.watched_movies.add(the_film) else: review_tip = 'musite prihlasit' if the_film.new_movie.frame is None: i_film = False else: if 'http://filman.cz' in the_film.new_movie.frame: i_film = False the_image = the_film.new_movie.image the_description = the_film.new_movie.description if '</span>' in the_description: #the_description.replace('<','').replace('>','').replace('span','').replace('id','').replace('class','').replace('more','').replace('-','').replace('/','') the_description = '' the_title = the_film.new_movie.title the_genera = the_film.new_movie.genera the_frame = the_film.new_movie.frame reviewed = UserMadeReview.objects.filter(is_film=True, obj_id=the_film.id) v = View(view_count=1) v.save() the_film.views.add(v) number_of_ratings = the_film.aggregate_rating.all().count() if number_of_ratings > 0: avg_rate = the_film.aggregate_rating.all().aggregate(Avg('ratingValue')) if avg_rate['ratingValue__avg'] is not None: if type(avg_rate) is not int: avg_rate = int(avg_rate['ratingValue__avg']) else: avg_rate = 0 else: avg_rate = 0 return render(request, 'films/fvideo.html', { 'is_film': i_film, 'the_title': the_title, 'the_description': the_description, 'the_genera': the_genera, 'the_image': the_image, 'the_frame': the_frame, 'film': the_film, 'reviewed': reviewed, 'user_not_auth': una, 'avg_rate': avg_rate, 'number_of_ratings': number_of_ratings, 'review_tip': review_tip, })