def generate_context(self, request, form, *args, **kwargs): exhibit_slug = form.cleaned_data.get("exhibit_slug") exhibit_owner = form.cleaned_data.get("exhibit_owner") # get Exhibit associated with this augmentation issue exhibit = DraftExhibit.objects.get(slug=exhibit_slug, owner__username=exhibit_owner) # check that current user has access to this exhibit if exhibit.owner.username != request.user.username: return HttpResponseBadRequest() # copy the exhibit for the support user support = get_user(settings.SUPPORT_USER) new_slug = str(uuid.uuid4()) exhibit.pk = None exhibit.id = None exhibit.parent = None exhibit.owner = support exhibit.slug = new_slug exhibit.save() old_exhibit = DraftExhibit.objects.get(slug=exhibit_slug) old_exhibit.duplicate_properties(exhibit) augmented_field_label = form.cleaned_data.get("label") augmented_field_type = form.cleaned_data.get("type") augmented_field_composite = form.cleaned_data.get("composite") c = super(AugmentationIssueView, self).generate_context(request, form) return dict( c, **{ "augmented_field_label": augmented_field_label, "augmented_field_type": augmented_field_type, "augmented_field_composite": augmented_field_composite, "exhibit_url": reverse("exhibit_property_editor", kwargs={"owner": support.username, "slug": new_slug}), } )
def generate_context(self, request, form, *args, **kwargs): exhibit_slug = form.cleaned_data.get("exhibit_slug") exhibit_owner = form.cleaned_data.get("exhibit_owner") # get Exhibit associated with this augmentation issue exhibit = DraftExhibit.objects.get(slug=exhibit_slug, owner__username=exhibit_owner) # check that current user has access to this exhibit if exhibit.owner.username != request.user.username: return HttpResponseBadRequest() # copy the exhibit for the support user support = get_user(settings.SUPPORT_USER) new_slug = str(uuid.uuid4()) exhibit.pk = None exhibit.id = None exhibit.parent = None exhibit.owner = support exhibit.slug = new_slug exhibit.save() old_exhibit = DraftExhibit.objects.get(slug=exhibit_slug) old_exhibit.duplicate_properties(exhibit) augmented_field_label = form.cleaned_data.get("label") augmented_field_type = form.cleaned_data.get("type") augmented_field_composite = form.cleaned_data.get("composite") c = super(AugmentationIssueView, self).generate_context(request, form) return dict( c, **{ "augmented_field_label": augmented_field_label, "augmented_field_type": augmented_field_type, "augmented_field_composite": augmented_field_composite, "exhibit_url": reverse('exhibit_property_editor', kwargs={ 'owner': support.username, 'slug': new_slug }) })
def get_object(self, request, owner=None): return get_user(username=owner)
def get_context_data(self,**kwargs): kwargs = super(ConnectionListByUserView, self).get_context_data(**kwargs) kwargs["other_user"] = get_user(self.kwargs.get("username")) return kwargs
def get_queryset(self): return Friendship.objects.friends_for_user(get_user(self.kwargs.get("username")))
def get_context_data(self, **kwargs): kwargs = super(ConnectionListByUserView, self).get_context_data(**kwargs) kwargs["other_user"] = get_user(self.kwargs.get("username")) return kwargs
def get_queryset(self): return Friendship.objects.friends_for_user( get_user(self.kwargs.get("username")))