Consistent hero-tabs navigation #244
@ -1 +1 @@
|
|||||||
Subproject commit d02f853634c2e490aa0eed3416ea3f63113ab60d
|
Subproject commit 2380780e143c20a77852bdd8d92da3a274726210
|
@ -112,12 +112,22 @@ class ExtensionsApprovalDetailView(DetailView):
|
|||||||
|
|
||||||
|
|
||||||
class ExtensionsApprovalFormView(LoginRequiredMixin, FormView):
|
class ExtensionsApprovalFormView(LoginRequiredMixin, FormView):
|
||||||
|
# TODO merge this view with DetailView
|
||||||
|
# there is no apparent benefit in keeping this form as its own view,
|
||||||
|
# but it does complicate error handling
|
||||||
form_class = CommentForm
|
form_class = CommentForm
|
||||||
http_method_names = ['post']
|
http_method_names = ['post']
|
||||||
|
template_name = 'reviewers/extensions_review_detail.html'
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse('reviewers:approval-detail', kwargs={'slug': self.kwargs['slug']})
|
return reverse('reviewers:approval-detail', kwargs={'slug': self.kwargs['slug']})
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
ctx = super().get_context_data(**kwargs)
|
||||||
|
ctx['comment_form'] = ctx['form']
|
||||||
|
ctx['extension'] = Extension.objects.get(slug=self.kwargs['slug'])
|
||||||
|
return ctx
|
||||||
|
|
||||||
def approve_if_allowed(self, form):
|
def approve_if_allowed(self, form):
|
||||||
if form.cleaned_data['type'] != ApprovalActivity.ActivityType.APPROVED:
|
if form.cleaned_data['type'] != ApprovalActivity.ActivityType.APPROVED:
|
||||||
return
|
return
|
||||||
|
3
utils.py
3
utils.py
@ -138,6 +138,9 @@ def get_client_ip(request: HttpRequest) -> str:
|
|||||||
"""
|
"""
|
||||||
x_forwarded_for: Optional[str] = request.META.get('HTTP_X_FORWARDED_FOR', None)
|
x_forwarded_for: Optional[str] = request.META.get('HTTP_X_FORWARDED_FOR', None)
|
||||||
if x_forwarded_for:
|
if x_forwarded_for:
|
||||||
|
# nginx's proxy_add_x_forwarded_for adds ', '
|
||||||
|
# we want to simplify the split, so removing all spaces first
|
||||||
|
x_forwarded_for = x_forwarded_for.replace(' ', '')
|
||||||
# X_FORWARDED_FOR returns client1, proxy1, proxy2,...
|
# X_FORWARDED_FOR returns client1, proxy1, proxy2,...
|
||||||
remote_addr = x_forwarded_for.split(',', 1)[0].strip()
|
remote_addr = x_forwarded_for.split(',', 1)[0].strip()
|
||||||
ip_address = _remove_port_nr(remote_addr)
|
ip_address = _remove_port_nr(remote_addr)
|
||||||
|
Loading…
Reference in New Issue
Block a user