mirror of https://github.com/doccano/doccano.git
pythonannotation-tooldatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learning
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.6 KiB
90 lines
2.6 KiB
import logging
|
|
|
|
from django.contrib.auth.views import LoginView as BaseLoginView
|
|
from django.shortcuts import get_object_or_404
|
|
from django.views.generic import TemplateView
|
|
from django.views.generic.list import ListView
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from .permissions import SuperUserMixin
|
|
from .models import Project
|
|
from app import settings
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class IndexView(TemplateView):
|
|
template_name = 'index.html'
|
|
|
|
|
|
class ProjectView(LoginRequiredMixin, TemplateView):
|
|
|
|
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):
|
|
template_name = 'projects.html'
|
|
|
|
|
|
class DatasetView(SuperUserMixin, LoginRequiredMixin, ListView):
|
|
template_name = 'admin/dataset.html'
|
|
paginate_by = 5
|
|
|
|
def get_queryset(self):
|
|
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
|
|
return project.documents.all()
|
|
|
|
|
|
class LabelView(SuperUserMixin, LoginRequiredMixin, TemplateView):
|
|
template_name = 'admin/label.html'
|
|
|
|
|
|
class StatsView(SuperUserMixin, LoginRequiredMixin, TemplateView):
|
|
template_name = 'admin/stats.html'
|
|
|
|
|
|
class GuidelineView(SuperUserMixin, LoginRequiredMixin, TemplateView):
|
|
template_name = 'admin/guideline.html'
|
|
|
|
|
|
class DataUpload(SuperUserMixin, LoginRequiredMixin, TemplateView):
|
|
|
|
def get_template_names(self):
|
|
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
|
|
return [project.get_upload_template()]
|
|
|
|
|
|
class DataDownload(SuperUserMixin, LoginRequiredMixin, TemplateView):
|
|
|
|
def get_template_names(self):
|
|
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
|
|
return [project.get_download_template()]
|
|
|
|
|
|
class LoginView(BaseLoginView):
|
|
template_name = 'login.html'
|
|
redirect_authenticated_user = True
|
|
extra_context = {
|
|
'github_login': bool(settings.SOCIAL_AUTH_GITHUB_KEY),
|
|
'aad_login': bool(settings.SOCIAL_AUTH_AZUREAD_TENANT_OAUTH2_TENANT_ID),
|
|
}
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super(LoginView, self).get_context_data(**kwargs)
|
|
context['social_login_enabled'] = any(value for key, value in context.items()
|
|
if key.endswith('_login'))
|
|
return context
|
|
|
|
|
|
class DemoTextClassification(TemplateView):
|
|
template_name = 'demo/demo_text_classification.html'
|
|
|
|
|
|
class DemoNamedEntityRecognition(TemplateView):
|
|
template_name = 'demo/demo_named_entity.html'
|
|
|
|
|
|
class DemoTranslation(TemplateView):
|
|
template_name = 'demo/demo_translation.html'
|