def updateSubtitle(request, subtitle_id): try: my_obj = Subtitle.objects.get(pk=subtitle_id) except ObjectDoesNotExist: raise Http404 form = SubtitleForm(request.POST or None, instance=my_obj) print(request.POST) # quick finish btn if 'quick_finish_btn' in request.POST: talk = my_obj.talk #finish current step if my_obj.transcription_in_progress: # transcribing done my_obj.time_processed_transcribing = talk.video_duration my_obj.state_id = 4 # Do not touch my_obj.needs_automatic_syncing = True my_obj.blocked = True elif my_obj.syncing_in_progress: # Syncing is done - if manually my_obj.time_processed_syncing = talk.video_duration my_obj.state_id = 7 # Quality check done until elif my_obj.quality_check_in_progress: # quality_check done my_obj.time_quality_check_done = talk.video_duration my_obj.state_id = 8 # Done # Execute Python Skript for Amara Sync in the Background?! elif my_obj.translation_in_progress: # Translation my_obj.time_processed_translating = talk.video_duration my_obj.state_id = 12 # Translation finished # Execute Python Skript for Amara Sync in the Background?! my_obj.save() messages.add_message(request, messages.INFO, 'Step finished.') return redirect('talk', talk_id=talk.pk) elif form.is_valid(): form.save() # do stuff my_obj.save() messages.add_message(request, messages.INFO, 'Subtitle Status is saved.') return redirect('talk', talk_id=my_obj.talk.pk) else: messages.add_message(request, messages.WARNING, 'You entered invalid data.') return redirect('talk', talk_id=my_obj.talk.pk)
def get_subtitle_form(request, talk, sub): """ * Wenn time_processed_transcribing < Talk.video_duration: o state_en nur id 1,2,3 oder 9 anzeigen, dahinter das Zeitfeld für time_processed_transcribing mit dem Wert aus der Datenbank und einem Button für "ok" und einem für "Transcribing done". + Wenn der User auf den "Transcribing done" Button drückt dann sollte die Talk.video_duration in das Feld für time_processed_transcribing geschrieben werden und der State sollte auf id 4 springen und ein Flag setzen (muss ich noch in das model rein machen) oder als workaround eine mal schicken. * Wenn time_processed_transcribing und time_processed_syncing = Talk.video_duration: o state_en nur id 6 und 7 anzeigen, dahinter den Zeitstempel für time_quality_check_done mit wert aus DB und buttons wie oben nur halt mit "Quality check done" + Wenn der User auf den "Translation finished" Button drückt dann sollte die Talk.video_duration in das Feld für time_quality_check_done geschrieben werden und der State sollte auf id 12 und complete = True markieren. * Für den Teil mit time_processed_syncing kann man das auch implementieren, ich hoffe es vorerst nicht zu brauchen, das wäre dann halt mit state id 5 und 6 und soll aber falls es als syncing fertig markiert wird auf state id 7 springen, die 6 (timing fertig) ist nur für den user da. *Übersetzung:* (kein is original flag) Ich grübel da noch ob das quality-check teil dazu sollte oder ob man beim Übersetzten auch einfach eine Person drann lässt?! Für den Fall ohne Quality check wäre es: * einmal das ganze mit state id 11 und 12 in der Anzeige vom dropdown menü und dem timestamp dazu aus der Datenbank von time_processed_translating + passende buttons. """ form = SubtitleForm(request.POST or None, instance=sub) if sub.blocked: #time_processed_transcribing == talk.video_duration != sub.time_processed_syncing: return "Automatic syncing, please wait and come back later!" if sub.complete: return "Finished :)" if sub.transcription_in_progress: # remove the unnecessary fields #form.fields.pop("time_processed_transcribing") form.fields.pop("time_processed_syncing") form.fields.pop("time_quality_check_done") form.fields.pop("time_processed_translating") # add finish transcribing button form.quick_btn = 'Finish Transcribing' return form elif sub.quality_check_in_progress: # remove the unnecessary fields form.fields.pop("time_processed_transcribing") form.fields.pop("time_processed_syncing") #form.fields.pop("time_quality_check_done") form.fields.pop("time_processed_translating") # add finish transcribing button form.quick_btn = 'Finish quality check' return form elif sub.translation_in_progress: # remove the unnecessary fields form.fields.pop("time_processed_transcribing") form.fields.pop("time_processed_syncing") form.fields.pop("time_quality_check_done") #form.fields.pop("time_processed_translating") # add finish transcribing button form.quick_btn = 'Finish Translating' return form return