Skip to content

Instantly share code, notes, and snippets.

@Bind
Created October 13, 2014 14:56
Show Gist options
  • Save Bind/2a2ffa11699987ff756d to your computer and use it in GitHub Desktop.
Save Bind/2a2ffa11699987ff756d to your computer and use it in GitHub Desktop.
app/views
class CompanyGalleryView(RegisteredUserMixin, ListView):
def get_queryset(self):
limit = self.request.user.default_investment_permission
queryset = super(CompanyGalleryView, self).get_queryset()
data = []
data = queryset.filter(company__investment_oppurtunity__user_investment_status__user=self.request.user, company__investment_oppurtunity__user_investment_status__investment_permission__gte=400)
data += queryset.filter(company__investment_status="po")
data.exclude(company__investment_oppurtunity__user_investment_status__user=self.request.user, company__investment_oppurtunity__user_investment_status__investment_permission__lte=300)
return data
def get_context_data(self, **kwargs):
context = super(CompanyGalleryView, self).get_context_data(**kwargs)
filter_val = self.request.user.landed_available_for_investment_filter
context["filter_val"] = "investment" if filter_val else "all"
self.request.user.landed_available_for_investment_filter = False
self.request.user.save()
return context
model = CompanyDisplay
context_object_name = "gallery_list"
template_name = "company_gallery.html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment