Browse Source

Simplify project view

pull/10/head
Hironsan 6 years ago
parent
commit
cdba3e0822
3 changed files with 6 additions and 13 deletions
  1. 2
      app/server/models.py
  2. 2
      app/server/templates/admin/dataset.html
  3. 15
      app/server/views.py

2
app/server/models.py

@ -38,7 +38,7 @@ class Project(models.Model):
return url
def get_template(self):
def get_template_name(self):
if self.is_type_of(Project.DOCUMENT_CLASSIFICATION):
template_name = 'annotation/document_classification.html'
elif self.is_type_of(Project.SEQUENCE_LABELING):

2
app/server/templates/admin/dataset.html

@ -19,7 +19,7 @@
</tr>
</thead>
<tbody>
{% for doc in documents %}
{% for doc in object_list %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ doc.text|truncatechars:200 }}</td>

15
app/server/views.py

@ -19,15 +19,10 @@ class IndexView(TemplateView):
class ProjectView(LoginRequiredMixin, TemplateView):
template_name = 'annotation.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
project_id = kwargs.get('project_id')
project = get_object_or_404(Project, pk=project_id)
self.template_name = project.get_template()
return context
def get_template_names(self):
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
return [project.get_template_name()]
class ProjectsView(LoginRequiredMixin, TemplateView):
@ -50,12 +45,10 @@ class ProjectsView(LoginRequiredMixin, TemplateView):
class DatasetView(SuperUserMixin, LoginRequiredMixin, ListView):
template_name = 'admin/dataset.html'
context_object_name = 'documents'
paginate_by = 5
def get_queryset(self):
project_id = self.kwargs['project_id']
project = get_object_or_404(Project, pk=project_id)
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
return project.documents.all()

Loading…
Cancel
Save