Ejemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     self.request_form = DomainRequestForm(request.POST)
     if self.request_form.is_valid():
         data = self.request_form.cleaned_data
         with CriticalSection(["domain_request_%s" % data['domain']]):
             if DomainRequest.by_email(data['domain'],
                                       data['email']) is not None:
                 messages.error(
                     request,
                     _("A request is pending for this email. "
                       "You will receive an email when the request is approved."
                       ))
             else:
                 domain_request = DomainRequest(**data)
                 domain_request.send_request_email()
                 domain_request.save()
                 domain = Domain.get_by_name(domain_request.domain)
                 return render(
                     request, "users/confirmation_sent.html", {
                         'hr_name':
                         domain.display_name()
                         if domain else domain_request.domain,
                         'url':
                         reverse("appstore"),
                     })
     return self.get(request, *args, **kwargs)
Ejemplo n.º 2
0
 def page_context(self):
     domain_obj = Domain.get_by_name(self.request.domain)
     if self.request_form is None:
         initial = {'domain': domain_obj.name}
         if self.request.user.is_authenticated:
             initial.update({
                 'email': self.request.user.get_username(),
                 'full_name': self.request.user.get_full_name(),
             })
         self.request_form = DomainRequestForm(initial=initial)
     return {
         'domain': domain_obj.name,
         'hr_name': domain_obj.display_name(),
         'request_form': self.request_form,
     }
Ejemplo n.º 3
0
 def post(self, request, *args, **kwargs):
     self.request_form = DomainRequestForm(request.POST)
     if self.request_form.is_valid():
         data = self.request_form.cleaned_data
         with CriticalSection(["domain_request_%s" % data["domain"]]):
             if DomainRequest.by_email(data["domain"], data["email"]) is not None:
                 messages.error(
                     request,
                     _(
                         "A request is pending for this email. "
                         "You will receive an email when the request is approved."
                     ),
                 )
             else:
                 domain_request = DomainRequest(**data)
                 domain_request.send_request_email()
                 domain_request.save()
                 domain = Domain.get_by_name(domain_request.domain)
                 return render(
                     request,
                     "users/confirmation_sent.html",
                     {
                         "hr_name": domain.display_name() if domain else domain_request.domain,
                         "url": reverse("appstore"),
                     },
                 )
     return self.get(request, *args, **kwargs)
Ejemplo n.º 4
0
 def page_context(self):
     domain = Domain.get_by_name(self.request.domain)
     if self.request_form is None:
         initial = {"domain": domain.name}
         if self.request.user.is_authenticated():
             initial.update(
                 {"email": self.request.user.get_username(), "full_name": self.request.user.get_full_name()}
             )
         self.request_form = DomainRequestForm(initial=initial)
     return {"domain": domain.name, "domain_name": domain.display_name(), "request_form": self.request_form}
Ejemplo n.º 5
0
class DomainRequestView(BasePageView):
    urlname = "domain_request"
    page_title = ugettext_lazy("Request Access")
    template_name = "users/domain_request.html"
    request_form = None

    @property
    def page_url(self):
        return reverse(self.urlname, args=[self.request.domain])

    @property
    def page_context(self):
        domain = Domain.get_by_name(self.request.domain)
        if self.request_form is None:
            initial = {'domain': domain.name}
            if self.request.user.is_authenticated():
                initial.update({
                    'email': self.request.user.get_username(),
                    'full_name': self.request.user.get_full_name(),
                })
            self.request_form = DomainRequestForm(initial=initial)
        return {
            'domain': domain.name,
            'domain_name': domain.display_name(),
            'request_form': self.request_form,
        }

    def post(self, request, *args, **kwargs):
        self.request_form = DomainRequestForm(request.POST)
        if self.request_form.is_valid():
            data = self.request_form.cleaned_data
            with CriticalSection(["domain_request_%s" % data['domain']]):
                if DomainRequest.by_email(data['domain'],
                                          data['email']) is not None:
                    messages.error(
                        request,
                        _("A request is pending for this email. "
                          "You will receive an email when the request is approved."
                          ))
                else:
                    domain_request = DomainRequest(**data)
                    domain_request.send_request_email()
                    domain_request.save()
                    domain = Domain.get_by_name(domain_request.domain)
                    return render(
                        request, "users/confirmation_sent.html", {
                            'hr_name':
                            domain.display_name()
                            if domain else domain_request.domain,
                            'url':
                            reverse("appstore"),
                        })
        return self.get(request, *args, **kwargs)
Ejemplo n.º 6
0
class DomainRequestView(BasePageView):
    urlname = "domain_request"
    page_title = ugettext_lazy("Request Access")
    template_name = "users/domain_request.html"
    request_form = None

    @property
    def page_url(self):
        return reverse(self.urlname, args=[self.request.domain])

    @property
    def page_context(self):
        domain = Domain.get_by_name(self.request.domain)
        if self.request_form is None:
            initial = {"domain": domain.name}
            if self.request.user.is_authenticated():
                initial.update(
                    {"email": self.request.user.get_username(), "full_name": self.request.user.get_full_name()}
                )
            self.request_form = DomainRequestForm(initial=initial)
        return {"domain": domain.name, "domain_name": domain.display_name(), "request_form": self.request_form}

    def post(self, request, *args, **kwargs):
        self.request_form = DomainRequestForm(request.POST)
        if self.request_form.is_valid():
            data = self.request_form.cleaned_data
            with CriticalSection(["domain_request_%s" % data["domain"]]):
                if DomainRequest.by_email(data["domain"], data["email"]) is not None:
                    messages.error(
                        request,
                        _(
                            "A request is pending for this email. "
                            "You will receive an email when the request is approved."
                        ),
                    )
                else:
                    domain_request = DomainRequest(**data)
                    domain_request.send_request_email()
                    domain_request.save()
                    domain = Domain.get_by_name(domain_request.domain)
                    return render(
                        request,
                        "users/confirmation_sent.html",
                        {
                            "hr_name": domain.display_name() if domain else domain_request.domain,
                            "url": reverse("appstore"),
                        },
                    )
        return self.get(request, *args, **kwargs)
Ejemplo n.º 7
0
 def page_context(self):
     domain = Domain.get_by_name(self.request.domain)
     if self.request_form is None:
         initial = {'domain': domain.name}
         if self.request.user.is_authenticated():
             initial.update({
                 'email': self.request.user.get_username(),
                 'full_name': self.request.user.get_full_name(),
             })
         self.request_form = DomainRequestForm(initial=initial)
     return {
         'domain': domain.name,
         'domain_name': domain.display_name(),
         'request_form': self.request_form,
     }