def generate_additional_review(self, song, i, score=None): if not score: score = i w = Writer.objects.create( username=i, email=i, first_name=i, last_name=i ) next_review = Review( song=song, writer=w, blurb="blurb %s" % i, score=score, status='saved' ) next_review.save()
def generate_additional_review(song, i, score=None, status='saved'): if not score: score = i w = Writer.objects.create( username=i, email=i, first_name=i, last_name=i ) next_review = Review( song=song, writer=w, blurb="blurb %s" % i, score=score, status=status, sort_order=i ) next_review.save() return next_review
def write_review(request, song_id, use_html=False): song = get_object_or_404(Song, id=song_id, status='open') try: review = Review.objects.get(writer=request.user, song=song) preview_text = True except Review.DoesNotExist: review = Review(writer=request.user, song=song) preview_text = False if request.method == 'POST': form = ReviewForm(data=request.POST, instance=review) if form.is_valid(): # Save the form review = form.save(commit=False) review.status = 'saved' review.save() if 'submit_and_return_to_songlist' in request.POST: return redirect('weekly_schedule') else: if use_html: return redirect('write_review_html', song_id=song.id) return redirect('write_review', song_id=song.id) else: form = ReviewForm(instance=review) return render( request, 'write_blurb.html', { 'form': form, 'song': song, 'preview_text': preview_text, 'use_html': use_html } )
def write_review(request, song_id, use_html=False): song = get_object_or_404(Song, id=song_id, status='open') try: review = Review.objects.get(writer=request.user, song=song) preview_text = True except Review.DoesNotExist: review = Review(writer=request.user, song=song) preview_text = False if request.method == 'POST': form = ReviewForm(data=request.POST, instance=review) if form.is_valid(): # Save the form review = form.save(commit=False) review.status = 'saved' # Copy backup of blurb (in case of admin change) review.blurb_backup = review.blurb review.save() if 'submit_and_return_to_songlist' in request.POST: return redirect('weekly_schedule') else: if use_html: return redirect('write_review_html', song_id=song.id) return redirect('write_review', song_id=song.id) else: form = ReviewForm(instance=review) return render( request, 'write_blurb.html', { 'form': form, 'song': song, 'preview_text': preview_text, 'use_html': use_html } )