def multimerge(request, slug): release = get_object_or_404(Release,slug=slug) is_coord = request.user.team_coordinator.filter(project=release.project).count()>0 is_maintainer = release.project.is_maintainer(request.user) if not is_coord and not is_maintainer: raise Http403 teams = None if request.method == 'POST': redirect = True files = [] for fid in request.POST.getlist('file'): files.append(POFile.objects.get(pk=fid)) if len(files)==0: raise Http404 from files.lib.handlers import process_merge fail=[] fileSet = POFileSubmitSet.objects.create() for pofile in files: try: fileSet.files.add(process_merge(pofile, request.user)) except Exception, e: logger.error(e) fail.append(str(e)) #fail.append(pofile) if len(fail)>0: if len(fail) == len(files): messages.error(request, _("The files could not be merged.")) messages.error(request, ", ".join(fail)) redirect = False else: messages.warning(request, _("Some files could not be merged.")) messages.warning(request, ", ".join(fail)) if redirect: if release.project.repo_user: needuser=False form = CommentForm() else: needuser=True form = HttpCredForm() messages.info(request, _("You are about to submit the following files.")) return render_to_response("files/file_submit_confirm.html", {'files': fileSet, 'back': reverse('multimerge', kwargs={'slug': slug}), 'form': form, 'needuser': needuser, 'reject': False, 'project': release.project.pk}, context_instance = RequestContext(request))
def do_merge(request, slug): pofile = get_object_or_404(POFile, slug=slug) redirect = HttpResponseRedirect(reverse('list_files', kwargs={'release': pofile.release.slug, 'language': pofile.language.code})) team = Team.objects.get(project=pofile.component.project, language=pofile.language) if not team.is_member(request.user) and not team.can_manage(request.user): messages.warning(request, message=_("You are not a member of this team.")) return redirect if pofile.submits.all_pending(): messages.warning(request, message=_("The file has a pending submit. You can't force a merge right now.")) return redirect if not pofile.potfile.all(): messages.error(request, message=_('POT file not found.')) return redirect try: filehandler.process_merge(pofile, request.user) except Exception, e: messages.error(request, message=str(e))