pass @oauth2_required @handle_errors def create_gdoc(request, client): """ Creation view of a :class:`.GoogleDocument`. """ if request.method == 'GET': creation_form = get_gdoc_creation_form(request.user, client) elif request.method == 'POST': creation_form = get_gdoc_creation_form(request.user, client, request.POST) return pviews.create_object(request, True, creation_form) register_creation_view(GoogleDocument, create_gdoc) @oauth2_required @handle_errors def display_files(request, client, obj_type, obj_ref, obj_revi): """ Files page of a GoogleDocument. """ obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) if not hasattr(obj, "files"): raise TypeError() try: entry = client.get_resource_by_id(obj.resource_id) edit_uri = "" if entry is not None:
@oauth2_required @handle_errors def create_gdoc(request, client): """ Creation view of a :class:`.GoogleDocument`. """ if request.method == 'GET': creation_form = get_gdoc_creation_form(request.user, client) elif request.method == 'POST': creation_form = get_gdoc_creation_form(request.user, client, request.POST) return pviews.create_object(request, True, creation_form) register_creation_view(GoogleDocument, create_gdoc) @oauth2_required @handle_errors def display_files(request, client, obj_type, obj_ref, obj_revi): """ Files page of a GoogleDocument. """ obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) if not hasattr(obj, "files"): raise TypeError() try: entry = client.get_resource_by_id(obj.resource_id) edit_uri = ""
role = form.cleaned_data["role"] obj.sponsor(new_user, role=="contributor", role=="restricted") return HttpResponseRedirect("..") else: form = forms.SponsorForm(initial=dict(sponsor=obj.id, language=obj.language), sponsor=obj.id) ctx["sponsor_form"] = form ctx['current_page'] = 'delegation' return r2r("users/sponsor.html", ctx, request) @handle_errors def create_user(request): url = request.user.profile.plmobject_url + "delegation/sponsor/" return HttpResponseRedirect(url) register_creation_view(User, create_user) @handle_errors def sponsor_resend_mail(request, obj_ref): obj, ctx = get_generic_data(request, "User", obj_ref) if request.method == "POST": try: link_id = request.POST["link_id"] link = models.DelegationLink.objects.get(id=int(link_id)) obj.resend_sponsor_mail(link.delegatee) msg = _("Mail resent to %(name)s") % {"name": link.delegatee.get_full_name()} messages.info(request, msg) except (KeyError, ValueError, ControllerError): return HttpResponseForbidden() return HttpResponseRedirect("../../")
from openPLM.plmapp.utils import r2r from openPLM.plmapp.views import create_object, get_pagination, ITEMS_PER_HISTORY, SimpleDateFilter from openPLM.plmapp.forms import PLMObjectForm from openPLM.apps.ecr.forms import get_creation_form from openPLM.apps.ecr.models import ECR, ECRHistory @bv.handle_errors def create_ecr(request, *args): if request.method == 'GET': creation_form = get_creation_form(request.user) elif request.method == 'POST': creation_form = get_creation_form(request.user, request.POST) return create_object(request, True, creation_form) bv.register_creation_view(ECR, create_ecr) @bv.handle_errors(restricted_access=False) def browse_ecr(request): user = request.user if not user.profile.restricted: # only authenticated users can see all groups and users obj, ctx = bv.get_generic_data(request, search=False) object_list = ECR.objects.all() # this is only relevant for authenticated users ctx["state"] = state = request.GET.get("state", "all") if state == "official": object_list = object_list.\ exclude(lifecycle=models.get_cancelled_lifecycle()).\ filter(state=F("lifecycle__official_state"))
else: form = forms.SponsorForm(initial=dict(sponsor=obj.id, language=obj.language), sponsor=obj.id) ctx["sponsor_form"] = form ctx['current_page'] = 'delegation' return r2r("users/sponsor.html", ctx, request) @handle_errors def create_user(request): url = request.user.profile.plmobject_url + "delegation/sponsor/" return HttpResponseRedirect(url) register_creation_view(User, create_user) @handle_errors def sponsor_resend_mail(request, obj_ref): obj, ctx = get_generic_data(request, "User", obj_ref) if request.method == "POST": try: link_id = request.POST["link_id"] link = models.DelegationLink.objects.get(id=int(link_id)) obj.resend_sponsor_mail(link.delegatee) msg = _("Mail resent to %(name)s") % { "name": link.delegatee.get_full_name() } messages.info(request, msg) except (KeyError, ValueError, ControllerError):