def edit_submit_file(request, slug): file = get_object_or_404(POFile, slug=slug) redirect = HttpResponseRedirect(reverse('commit_queue')) if request.method == 'POST': if request.POST.has_key('_save'): form = FileEditForm(request.POST) if form.is_valid(): try: filehandler.handle_text_file(file, form.cleaned_data['content'], request.user, form.cleaned_data['comment']) messages.info(request, message=_("The file was added back to the submission queue.")) return redirect except Exception, e: res = e.message.split("$$") for m in res: messages.error(request, message=m[:-1]) else: if file.submits.all_pending(): s = file.submits.get_pending() s.enabled = True s.save() return redirect
def edit_file(request, slug): file = get_object_or_404(POFile, slug=slug) redirect = HttpResponseRedirect(reverse('list_files', kwargs={'release': file.release.slug, 'language': file.language.code})) if request.method == 'POST': if request.POST.has_key('_save'): form = FileEditForm(request.POST) if form.is_valid(): try: filehandler.handle_text_file(file, form.cleaned_data['content'], request.user, form.cleaned_data['comment']) messages.info(request, message=_("%s was added to the submission queue.") % file.filename) return redirect except Exception, e: res = str(e).split("$$") for m in res: messages.error(request, message=m[:-1]) else: if file.submits.all_pending(): s = file.submits.get_pending() s.enabled = True s.save() return redirect
@xmlrpc("get_user") def do_get_user(user_id): return parse(User.objects.get(id=user_id), exclude=["password", "email", "last_login", "date_joined"]) @xmlrpc("upload_file") @verify_token def do_upload_file(file_id, data, user): logger.debug("Upload file %s by %s" % (file_id, user)) try: file = POFile.objects.get(id=file_id, locks__owner=user) except POFile.DoesNotExist: # file is not locked by the user logger.debug("Not locked") return "[ERR101]: %s" % _("File is not locked.") except Exception, e: logger.error(e) return "[ERR999]: %s" % _("Failed: [%s].") % e else: handle_text_file(file, base64.b64decode(data).decode("utf-8"), user) return "OK" @xmlrpc("get_file_content") def do_get_file(file_id): file = POFile.objects.get(id=file_id) content = file.handler.get_content(True) return base64.b64encode(content)