We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
We need to update the landing page
With the recent work to create project pages, the landing page now contains superfluous content. Please update it to remove the changelog entries so that it becomes a project gallery. Clicking into a project will go to the project landing page. From the project landing page the user can then go into their changelogs etc.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `django_project/base/views/project.py`
Content:
```
1 # coding=utf-8
2 """Views for projects."""
3 # noinspection PyUnresolvedReferences
4 import logging
5 from django.core.urlresolvers import reverse
6 from django.http import Http404
7 from django.shortcuts import get_object_or_404
8 from django.views.generic import (
9     ListView,
10     CreateView,
11     DeleteView,
12     DetailView,
13     UpdateView,
14     RedirectView,
15 )
16 from braces.views import LoginRequiredMixin, StaffuserRequiredMixin
17 from pure_pagination.mixins import PaginationMixin
18 from changes.models import Version
19 from ..models import Project
20 from ..forms import ProjectForm, ScreenshotFormset
21 from vota.models import Committee, Ballot
22 from changes.models import SponsorshipPeriod
23 from certification.models import CertifyingOrganisation
24 from django.conf import settings
25 from django.shortcuts import redirect
26 
27 logger = logging.getLogger(__name__)
28 
29 
30 class ProjectMixin(object):
31     model = Project
32     form_class = ProjectForm
33 
34 
35 class ProjectBallotListView(ProjectMixin, PaginationMixin, DetailView):
36     """List all ballots within in a project"""
37     context_object_name = 'project'
38     template_name = 'project/ballot-list.html'
39     paginate_by = 1000
40 
41     def get_context_data(self, **kwargs):
42         context = super(
43             ProjectBallotListView, self).get_context_data(**kwargs)
44         committees = Committee.objects.filter(project=self.object)
45         ballots = []
46         for committee in committees:
47             if self.request.user.is_authenticated and \
48                     self.request.user in committee.users.all():
49                     committee_ballots = Ballot.objects.filter(
50                         committee=committee)
51             else:
52                 committee_ballots = Ballot.objects.filter(
53                     committee=committee).filter(private=False)
54             if committee_ballots:
55                 ballots.append(committee_ballots)
56         context['ballots_list'] = ballots
57         return context
58 
59     def get_queryset(self):
60         if self.request.user.is_authenticated():
61             projects_qs = Project.approved_objects.all()
62         else:
63             projects_qs = Project.public_objects.all()
64         return projects_qs
65 
66 
67 class ProjectListView(ProjectMixin, PaginationMixin, ListView):
68     """List all approved projects"""
69     context_object_name = 'projects'
70     template_name = 'project/list.html'
71     paginate_by = 1000
72 
73     def get_context_data(self, **kwargs):
74         """Add to the view's context data
75 
76         :param kwargs: (django dictionary)
77         :type kwargs: dict
78 
79         :return: context
80         :rtype: dict
81 
82         """
83         context = super(ProjectListView, self).get_context_data(**kwargs)
84         context['num_projects'] = self.get_queryset().count()
85         context[
86             'PROJECT_VERSION_LIST_SIZE'] = settings.PROJECT_VERSION_LIST_SIZE
87         if self.request.user.is_authenticated():
88             project = Project.objects.filter(owner=self.request.user)
89             pending_organisation = CertifyingOrganisation.objects.filter(
90                 project=project, approved=False
91             )
92             context['num_project_with_pending'] = 0
93             if pending_organisation:
94                 context['project_with_pending'] = []
95 
96                 for organisation in pending_organisation:
97                     if organisation.project not in \
98                             context['project_with_pending']:
99                         context['project_with_pending'].append(
100                             organisation.project)
101                         context['num_project_with_pending'] += 1
102                 context['message'] = \
103                     'You have a pending organisation approval. '
104         return context
105 
106     def get_queryset(self):
107         """Specify the queryset
108 
109         Return a specific queryset based on the requesting user's status
110 
111         :return: If user.is_authenticated: All approved projects
112             If not user.is_authenticated: All public projects
113         :rtype: QuerySet
114 
115         """
116         if self.request.user.is_authenticated():
117             projects_qs = Project.approved_objects.all()
118         else:
119             projects_qs = Project.public_objects.all()
120         return projects_qs
121 
122 
123 class ProjectDetailView(ProjectMixin, DetailView):
124     context_object_name = 'project'
125     template_name = 'project/new_detail.html'
126 
127     def get_context_data(self, **kwargs):
128         context = super(ProjectDetailView, self).get_context_data(**kwargs)
129         context['projects'] = self.get_queryset()
130         context['committees'] = Committee.objects.filter(project=self.object)
131         context['versions'] = Version.objects.filter(
132             project=self.object).order_by('-padded_version')[:5]
133         context['sponsors'] = \
134             SponsorshipPeriod.objects.filter(
135                 project=self.object).order_by('-sponsorship_level__value')
136         context['screenshots'] = self.object.screenshots.all()
137         return context
138 
139     def get_queryset(self):
140         projects_qs = Project.approved_objects.all()
141         return projects_qs
142 
143     def get_object(self, queryset=None):
144         obj = super(ProjectDetailView, self).get_object(queryset)
145         obj.request_user = self.request.user
146         return obj
147 
148 
149 class ProjectDeleteView(LoginRequiredMixin, ProjectMixin, DeleteView):
150     context_object_name = 'project'
151     template_name = 'project/delete.html'
152 
153     def get_success_url(self):
154         return reverse('project-list')
155 
156     def get_queryset(self):
157         if not self.request.user.is_authenticated():
158             raise Http404
159 
160         qs = Project.objects.all()
161         if self.request.user.is_staff:
162             return qs
163         else:
164             return qs.filter(owner=self.request.user)
165 
166 
167 class ProjectCreateView(LoginRequiredMixin, ProjectMixin, CreateView):
168     context_object_name = 'project'
169     template_name = 'project/create.html'
170 
171     def get_success_url(self):
172         return reverse('pending-project-list')
173 
174     def get_form_kwargs(self):
175         kwargs = super(ProjectCreateView, self).get_form_kwargs()
176         kwargs.update({'user': self.request.user})
177         return kwargs
178 
179     def get_context_data(self, **kwargs):
180         context = super(ProjectCreateView, self).get_context_data(**kwargs)
181         if self.request.POST:
182             context['formset'] = \
183                 ScreenshotFormset(self.request.POST, self.request.FILES)
184         else:
185             context['formset'] = ScreenshotFormset()
186         return context
187 
188     def form_valid(self, form):
189         """Check that form and formset are valid."""
190         context = self.get_context_data()
191         formset = context['formset']
192         if formset.is_valid() and form.is_valid():
193             object = form.save()
194             formset.instance = object
195             formset.save()
196             return redirect(self.get_success_url())
197         else:
198             return self.render_to_response(self.get_context_data(form=form))
199 
200 
201 class ProjectUpdateView(LoginRequiredMixin, ProjectMixin, UpdateView):
202     context_object_name = 'project'
203     template_name = 'project/update.html'
204 
205     def get_form_kwargs(self):
206         kwargs = super(ProjectUpdateView, self).get_form_kwargs()
207         kwargs.update({'user': self.request.user})
208         return kwargs
209 
210     def get_queryset(self):
211         qs = Project.objects
212         if self.request.user.is_staff:
213             return qs
214         else:
215             return qs.filter(owner=self.request.user)
216 
217     def get_context_data(self, **kwargs):
218         context = super(ProjectUpdateView, self).get_context_data(**kwargs)
219         if self.request.POST:
220             context['formset'] = \
221                 ScreenshotFormset(
222                     self.request.POST,
223                     self.request.FILES,
224                     instance=self.object)
225         else:
226             context['formset'] = ScreenshotFormset(instance=self.object)
227         return context
228 
229     def get_success_url(self):
230         if self.object.approved:
231             return reverse('project-detail', kwargs={'slug': self.object.slug})
232         else:
233             return reverse('pending-project-list')
234 
235     def form_valid(self, form):
236         """Check that form and formset are valid."""
237         context = self.get_context_data()
238         formset = context['formset']
239         if formset.is_valid() and form.is_valid():
240             object = form.save()
241             formset.instance = object
242             formset.save()
243             return redirect(self.get_success_url())
244         else:
245             return self.render_to_response(self.get_context_data(form=form))
246 
247 
248 class PendingProjectListView(
249         ProjectMixin,
250         PaginationMixin,
251         ListView,
252         StaffuserRequiredMixin,
253         LoginRequiredMixin):
254     """List all users unapproved projects - staff users see all unapproved."""
255     context_object_name = 'projects'
256     template_name = 'project/list.html'
257     paginate_by = settings.PROJECT_VERSION_LIST_SIZE
258 
259     def get_queryset(self):
260         projects_qs = Project.unapproved_objects.all()
261         if self.request.user.is_staff:
262             return projects_qs
263         else:
264             try:
265                 return projects_qs.filter(owner=self.request.user)
266             except TypeError:
267                 # LoginRequiredMixin should really be catching this...
268                 raise Http404('You must be logged in to see pending projects.')
269 
270     def get_context_data(self, **kwargs):
271         context = super(
272             PendingProjectListView, self).get_context_data(**kwargs)
273         context['num_projects'] = self.get_queryset().count()
274         context['unapproved'] = True
275         return context
276 
277 
278 class ApproveProjectView(StaffuserRequiredMixin, ProjectMixin, RedirectView):
279     permanent = False
280     query_string = True
281     pattern_name = 'pending-project-list'
282 
283     def get_redirect_url(self, slug):
284         projects_qs = Project.unapproved_objects.all()
285         project = get_object_or_404(projects_qs, slug=slug)
286         project.approved = True
287         project.save()
288         return reverse(self.pattern_name)
289
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/django_project/base/views/project.py b/django_project/base/views/project.py
--- a/django_project/base/views/project.py
+++ b/django_project/base/views/project.py
@@ -134,6 +134,9 @@
             SponsorshipPeriod.objects.filter(
                 project=self.object).order_by('-sponsorship_level__value')
         context['screenshots'] = self.object.screenshots.all()
+        context['organisations'] = \
+            CertifyingOrganisation.objects.filter(
+                project=self.object, approved=True)
         return context
 
     def get_queryset(self):

{"golden_diff": "diff --git a/django_project/base/views/project.py b/django_project/base/views/project.py\n--- a/django_project/base/views/project.py\n+++ b/django_project/base/views/project.py\n@@ -134,6 +134,9 @@\n             SponsorshipPeriod.objects.filter(\n                 project=self.object).order_by('-sponsorship_level__value')\n         context['screenshots'] = self.object.screenshots.all()\n+        context['organisations'] = \\\n+            CertifyingOrganisation.objects.filter(\n+                project=self.object, approved=True)\n         return context\n \n     def get_queryset(self):\n", "issue": "We need to update the landing page\nWith the recent work to create project pages, the landing page now contains superfluous content. Please update it to remove the changelog entries so that it becomes a project gallery. Clicking into a project will go to the project landing page. From the project landing page the user can then go into their changelogs etc.\n", "before_files": [{"content": "# coding=utf-8\n\"\"\"Views for projects.\"\"\"\n# noinspection PyUnresolvedReferences\nimport logging\nfrom django.core.urlresolvers import reverse\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404\nfrom django.views.generic import (\n    ListView,\n    CreateView,\n    DeleteView,\n    DetailView,\n    UpdateView,\n    RedirectView,\n)\nfrom braces.views import LoginRequiredMixin, StaffuserRequiredMixin\nfrom pure_pagination.mixins import PaginationMixin\nfrom changes.models import Version\nfrom ..models import Project\nfrom ..forms import ProjectForm, ScreenshotFormset\nfrom vota.models import Committee, Ballot\nfrom changes.models import SponsorshipPeriod\nfrom certification.models import CertifyingOrganisation\nfrom django.conf import settings\nfrom django.shortcuts import redirect\n\nlogger = logging.getLogger(__name__)\n\n\nclass ProjectMixin(object):\n    model = Project\n    form_class = ProjectForm\n\n\nclass ProjectBallotListView(ProjectMixin, PaginationMixin, DetailView):\n    \"\"\"List all ballots within in a project\"\"\"\n    context_object_name = 'project'\n    template_name = 'project/ballot-list.html'\n    paginate_by = 1000\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            ProjectBallotListView, self).get_context_data(**kwargs)\n        committees = Committee.objects.filter(project=self.object)\n        ballots = []\n        for committee in committees:\n            if self.request.user.is_authenticated and \\\n                    self.request.user in committee.users.all():\n                    committee_ballots = Ballot.objects.filter(\n                        committee=committee)\n            else:\n                committee_ballots = Ballot.objects.filter(\n                    committee=committee).filter(private=False)\n            if committee_ballots:\n                ballots.append(committee_ballots)\n        context['ballots_list'] = ballots\n        return context\n\n    def get_queryset(self):\n        if self.request.user.is_authenticated():\n            projects_qs = Project.approved_objects.all()\n        else:\n            projects_qs = Project.public_objects.all()\n        return projects_qs\n\n\nclass ProjectListView(ProjectMixin, PaginationMixin, ListView):\n    \"\"\"List all approved projects\"\"\"\n    context_object_name = 'projects'\n    template_name = 'project/list.html'\n    paginate_by = 1000\n\n    def get_context_data(self, **kwargs):\n        \"\"\"Add to the view's context data\n\n        :param kwargs: (django dictionary)\n        :type kwargs: dict\n\n        :return: context\n        :rtype: dict\n\n        \"\"\"\n        context = super(ProjectListView, self).get_context_data(**kwargs)\n        context['num_projects'] = self.get_queryset().count()\n        context[\n            'PROJECT_VERSION_LIST_SIZE'] = settings.PROJECT_VERSION_LIST_SIZE\n        if self.request.user.is_authenticated():\n            project = Project.objects.filter(owner=self.request.user)\n            pending_organisation = CertifyingOrganisation.objects.filter(\n                project=project, approved=False\n            )\n            context['num_project_with_pending'] = 0\n            if pending_organisation:\n                context['project_with_pending'] = []\n\n                for organisation in pending_organisation:\n                    if organisation.project not in \\\n                            context['project_with_pending']:\n                        context['project_with_pending'].append(\n                            organisation.project)\n                        context['num_project_with_pending'] += 1\n                context['message'] = \\\n                    'You have a pending organisation approval. '\n        return context\n\n    def get_queryset(self):\n        \"\"\"Specify the queryset\n\n        Return a specific queryset based on the requesting user's status\n\n        :return: If user.is_authenticated: All approved projects\n            If not user.is_authenticated: All public projects\n        :rtype: QuerySet\n\n        \"\"\"\n        if self.request.user.is_authenticated():\n            projects_qs = Project.approved_objects.all()\n        else:\n            projects_qs = Project.public_objects.all()\n        return projects_qs\n\n\nclass ProjectDetailView(ProjectMixin, DetailView):\n    context_object_name = 'project'\n    template_name = 'project/new_detail.html'\n\n    def get_context_data(self, **kwargs):\n        context = super(ProjectDetailView, self).get_context_data(**kwargs)\n        context['projects'] = self.get_queryset()\n        context['committees'] = Committee.objects.filter(project=self.object)\n        context['versions'] = Version.objects.filter(\n            project=self.object).order_by('-padded_version')[:5]\n        context['sponsors'] = \\\n            SponsorshipPeriod.objects.filter(\n                project=self.object).order_by('-sponsorship_level__value')\n        context['screenshots'] = self.object.screenshots.all()\n        return context\n\n    def get_queryset(self):\n        projects_qs = Project.approved_objects.all()\n        return projects_qs\n\n    def get_object(self, queryset=None):\n        obj = super(ProjectDetailView, self).get_object(queryset)\n        obj.request_user = self.request.user\n        return obj\n\n\nclass ProjectDeleteView(LoginRequiredMixin, ProjectMixin, DeleteView):\n    context_object_name = 'project'\n    template_name = 'project/delete.html'\n\n    def get_success_url(self):\n        return reverse('project-list')\n\n    def get_queryset(self):\n        if not self.request.user.is_authenticated():\n            raise Http404\n\n        qs = Project.objects.all()\n        if self.request.user.is_staff:\n            return qs\n        else:\n            return qs.filter(owner=self.request.user)\n\n\nclass ProjectCreateView(LoginRequiredMixin, ProjectMixin, CreateView):\n    context_object_name = 'project'\n    template_name = 'project/create.html'\n\n    def get_success_url(self):\n        return reverse('pending-project-list')\n\n    def get_form_kwargs(self):\n        kwargs = super(ProjectCreateView, self).get_form_kwargs()\n        kwargs.update({'user': self.request.user})\n        return kwargs\n\n    def get_context_data(self, **kwargs):\n        context = super(ProjectCreateView, self).get_context_data(**kwargs)\n        if self.request.POST:\n            context['formset'] = \\\n                ScreenshotFormset(self.request.POST, self.request.FILES)\n        else:\n            context['formset'] = ScreenshotFormset()\n        return context\n\n    def form_valid(self, form):\n        \"\"\"Check that form and formset are valid.\"\"\"\n        context = self.get_context_data()\n        formset = context['formset']\n        if formset.is_valid() and form.is_valid():\n            object = form.save()\n            formset.instance = object\n            formset.save()\n            return redirect(self.get_success_url())\n        else:\n            return self.render_to_response(self.get_context_data(form=form))\n\n\nclass ProjectUpdateView(LoginRequiredMixin, ProjectMixin, UpdateView):\n    context_object_name = 'project'\n    template_name = 'project/update.html'\n\n    def get_form_kwargs(self):\n        kwargs = super(ProjectUpdateView, self).get_form_kwargs()\n        kwargs.update({'user': self.request.user})\n        return kwargs\n\n    def get_queryset(self):\n        qs = Project.objects\n        if self.request.user.is_staff:\n            return qs\n        else:\n            return qs.filter(owner=self.request.user)\n\n    def get_context_data(self, **kwargs):\n        context = super(ProjectUpdateView, self).get_context_data(**kwargs)\n        if self.request.POST:\n            context['formset'] = \\\n                ScreenshotFormset(\n                    self.request.POST,\n                    self.request.FILES,\n                    instance=self.object)\n        else:\n            context['formset'] = ScreenshotFormset(instance=self.object)\n        return context\n\n    def get_success_url(self):\n        if self.object.approved:\n            return reverse('project-detail', kwargs={'slug': self.object.slug})\n        else:\n            return reverse('pending-project-list')\n\n    def form_valid(self, form):\n        \"\"\"Check that form and formset are valid.\"\"\"\n        context = self.get_context_data()\n        formset = context['formset']\n        if formset.is_valid() and form.is_valid():\n            object = form.save()\n            formset.instance = object\n            formset.save()\n            return redirect(self.get_success_url())\n        else:\n            return self.render_to_response(self.get_context_data(form=form))\n\n\nclass PendingProjectListView(\n        ProjectMixin,\n        PaginationMixin,\n        ListView,\n        StaffuserRequiredMixin,\n        LoginRequiredMixin):\n    \"\"\"List all users unapproved projects - staff users see all unapproved.\"\"\"\n    context_object_name = 'projects'\n    template_name = 'project/list.html'\n    paginate_by = settings.PROJECT_VERSION_LIST_SIZE\n\n    def get_queryset(self):\n        projects_qs = Project.unapproved_objects.all()\n        if self.request.user.is_staff:\n            return projects_qs\n        else:\n            try:\n                return projects_qs.filter(owner=self.request.user)\n            except TypeError:\n                # LoginRequiredMixin should really be catching this...\n                raise Http404('You must be logged in to see pending projects.')\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            PendingProjectListView, self).get_context_data(**kwargs)\n        context['num_projects'] = self.get_queryset().count()\n        context['unapproved'] = True\n        return context\n\n\nclass ApproveProjectView(StaffuserRequiredMixin, ProjectMixin, RedirectView):\n    permanent = False\n    query_string = True\n    pattern_name = 'pending-project-list'\n\n    def get_redirect_url(self, slug):\n        projects_qs = Project.unapproved_objects.all()\n        project = get_object_or_404(projects_qs, slug=slug)\n        project.approved = True\n        project.save()\n        return reverse(self.pattern_name)\n", "path": "django_project/base/views/project.py"}], "after_files": [{"content": "# coding=utf-8\n\"\"\"Views for projects.\"\"\"\n# noinspection PyUnresolvedReferences\nimport logging\nfrom django.core.urlresolvers import reverse\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404\nfrom django.views.generic import (\n    ListView,\n    CreateView,\n    DeleteView,\n    DetailView,\n    UpdateView,\n    RedirectView,\n)\nfrom braces.views import LoginRequiredMixin, StaffuserRequiredMixin\nfrom pure_pagination.mixins import PaginationMixin\nfrom changes.models import Version\nfrom ..models import Project\nfrom ..forms import ProjectForm, ScreenshotFormset\nfrom vota.models import Committee, Ballot\nfrom changes.models import SponsorshipPeriod\nfrom certification.models import CertifyingOrganisation\nfrom django.conf import settings\nfrom django.shortcuts import redirect\n\nlogger = logging.getLogger(__name__)\n\n\nclass ProjectMixin(object):\n    model = Project\n    form_class = ProjectForm\n\n\nclass ProjectBallotListView(ProjectMixin, PaginationMixin, DetailView):\n    \"\"\"List all ballots within in a project\"\"\"\n    context_object_name = 'project'\n    template_name = 'project/ballot-list.html'\n    paginate_by = 1000\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            ProjectBallotListView, self).get_context_data(**kwargs)\n        committees = Committee.objects.filter(project=self.object)\n        ballots = []\n        for committee in committees:\n            if self.request.user.is_authenticated and \\\n                    self.request.user in committee.users.all():\n                    committee_ballots = Ballot.objects.filter(\n                        committee=committee)\n            else:\n                committee_ballots = Ballot.objects.filter(\n                    committee=committee).filter(private=False)\n            if committee_ballots:\n                ballots.append(committee_ballots)\n        context['ballots_list'] = ballots\n        return context\n\n    def get_queryset(self):\n        if self.request.user.is_authenticated():\n            projects_qs = Project.approved_objects.all()\n        else:\n            projects_qs = Project.public_objects.all()\n        return projects_qs\n\n\nclass ProjectListView(ProjectMixin, PaginationMixin, ListView):\n    \"\"\"List all approved projects\"\"\"\n    context_object_name = 'projects'\n    template_name = 'project/list.html'\n    paginate_by = 1000\n\n    def get_context_data(self, **kwargs):\n        \"\"\"Add to the view's context data\n\n        :param kwargs: (django dictionary)\n        :type kwargs: dict\n\n        :return: context\n        :rtype: dict\n\n        \"\"\"\n        context = super(ProjectListView, self).get_context_data(**kwargs)\n        context['num_projects'] = self.get_queryset().count()\n        context[\n            'PROJECT_VERSION_LIST_SIZE'] = settings.PROJECT_VERSION_LIST_SIZE\n        if self.request.user.is_authenticated():\n            project = Project.objects.filter(owner=self.request.user)\n            pending_organisation = CertifyingOrganisation.objects.filter(\n                project=project, approved=False\n            )\n            context['num_project_with_pending'] = 0\n            if pending_organisation:\n                context['project_with_pending'] = []\n\n                for organisation in pending_organisation:\n                    if organisation.project not in \\\n                            context['project_with_pending']:\n                        context['project_with_pending'].append(\n                            organisation.project)\n                        context['num_project_with_pending'] += 1\n                context['message'] = \\\n                    'You have a pending organisation approval. '\n        return context\n\n    def get_queryset(self):\n        \"\"\"Specify the queryset\n\n        Return a specific queryset based on the requesting user's status\n\n        :return: If user.is_authenticated: All approved projects\n            If not user.is_authenticated: All public projects\n        :rtype: QuerySet\n\n        \"\"\"\n        if self.request.user.is_authenticated():\n            projects_qs = Project.approved_objects.all()\n        else:\n            projects_qs = Project.public_objects.all()\n        return projects_qs\n\n\nclass ProjectDetailView(ProjectMixin, DetailView):\n    context_object_name = 'project'\n    template_name = 'project/new_detail.html'\n\n    def get_context_data(self, **kwargs):\n        context = super(ProjectDetailView, self).get_context_data(**kwargs)\n        context['projects'] = self.get_queryset()\n        context['committees'] = Committee.objects.filter(project=self.object)\n        context['versions'] = Version.objects.filter(\n            project=self.object).order_by('-padded_version')[:5]\n        context['sponsors'] = \\\n            SponsorshipPeriod.objects.filter(\n                project=self.object).order_by('-sponsorship_level__value')\n        context['screenshots'] = self.object.screenshots.all()\n        context['organisations'] = \\\n            CertifyingOrganisation.objects.filter(\n                project=self.object, approved=True)\n        return context\n\n    def get_queryset(self):\n        projects_qs = Project.approved_objects.all()\n        return projects_qs\n\n    def get_object(self, queryset=None):\n        obj = super(ProjectDetailView, self).get_object(queryset)\n        obj.request_user = self.request.user\n        return obj\n\n\nclass ProjectDeleteView(LoginRequiredMixin, ProjectMixin, DeleteView):\n    context_object_name = 'project'\n    template_name = 'project/delete.html'\n\n    def get_success_url(self):\n        return reverse('project-list')\n\n    def get_queryset(self):\n        if not self.request.user.is_authenticated():\n            raise Http404\n\n        qs = Project.objects.all()\n        if self.request.user.is_staff:\n            return qs\n        else:\n            return qs.filter(owner=self.request.user)\n\n\nclass ProjectCreateView(LoginRequiredMixin, ProjectMixin, CreateView):\n    context_object_name = 'project'\n    template_name = 'project/create.html'\n\n    def get_success_url(self):\n        return reverse('pending-project-list')\n\n    def get_form_kwargs(self):\n        kwargs = super(ProjectCreateView, self).get_form_kwargs()\n        kwargs.update({'user': self.request.user})\n        return kwargs\n\n    def get_context_data(self, **kwargs):\n        context = super(ProjectCreateView, self).get_context_data(**kwargs)\n        if self.request.POST:\n            context['formset'] = \\\n                ScreenshotFormset(self.request.POST, self.request.FILES)\n        else:\n            context['formset'] = ScreenshotFormset()\n        return context\n\n    def form_valid(self, form):\n        \"\"\"Check that form and formset are valid.\"\"\"\n        context = self.get_context_data()\n        formset = context['formset']\n        if formset.is_valid() and form.is_valid():\n            object = form.save()\n            formset.instance = object\n            formset.save()\n            return redirect(self.get_success_url())\n        else:\n            return self.render_to_response(self.get_context_data(form=form))\n\n\nclass ProjectUpdateView(LoginRequiredMixin, ProjectMixin, UpdateView):\n    context_object_name = 'project'\n    template_name = 'project/update.html'\n\n    def get_form_kwargs(self):\n        kwargs = super(ProjectUpdateView, self).get_form_kwargs()\n        kwargs.update({'user': self.request.user})\n        return kwargs\n\n    def get_queryset(self):\n        qs = Project.objects\n        if self.request.user.is_staff:\n            return qs\n        else:\n            return qs.filter(owner=self.request.user)\n\n    def get_context_data(self, **kwargs):\n        context = super(ProjectUpdateView, self).get_context_data(**kwargs)\n        if self.request.POST:\n            context['formset'] = \\\n                ScreenshotFormset(\n                    self.request.POST,\n                    self.request.FILES,\n                    instance=self.object)\n        else:\n            context['formset'] = ScreenshotFormset(instance=self.object)\n        return context\n\n    def get_success_url(self):\n        if self.object.approved:\n            return reverse('project-detail', kwargs={'slug': self.object.slug})\n        else:\n            return reverse('pending-project-list')\n\n    def form_valid(self, form):\n        \"\"\"Check that form and formset are valid.\"\"\"\n        context = self.get_context_data()\n        formset = context['formset']\n        if formset.is_valid() and form.is_valid():\n            object = form.save()\n            formset.instance = object\n            formset.save()\n            return redirect(self.get_success_url())\n        else:\n            return self.render_to_response(self.get_context_data(form=form))\n\n\nclass PendingProjectListView(\n        ProjectMixin,\n        PaginationMixin,\n        ListView,\n        StaffuserRequiredMixin,\n        LoginRequiredMixin):\n    \"\"\"List all users unapproved projects - staff users see all unapproved.\"\"\"\n    context_object_name = 'projects'\n    template_name = 'project/list.html'\n    paginate_by = settings.PROJECT_VERSION_LIST_SIZE\n\n    def get_queryset(self):\n        projects_qs = Project.unapproved_objects.all()\n        if self.request.user.is_staff:\n            return projects_qs\n        else:\n            try:\n                return projects_qs.filter(owner=self.request.user)\n            except TypeError:\n                # LoginRequiredMixin should really be catching this...\n                raise Http404('You must be logged in to see pending projects.')\n\n    def get_context_data(self, **kwargs):\n        context = super(\n            PendingProjectListView, self).get_context_data(**kwargs)\n        context['num_projects'] = self.get_queryset().count()\n        context['unapproved'] = True\n        return context\n\n\nclass ApproveProjectView(StaffuserRequiredMixin, ProjectMixin, RedirectView):\n    permanent = False\n    query_string = True\n    pattern_name = 'pending-project-list'\n\n    def get_redirect_url(self, slug):\n        projects_qs = Project.unapproved_objects.all()\n        project = get_object_or_404(projects_qs, slug=slug)\n        project.approved = True\n        project.save()\n        return reverse(self.pattern_name)\n", "path": "django_project/base/views/project.py"}]}