From 0d83f4bf66e58775b1d66cfc1e77696163f756ef Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 28 May 2018 12:41:58 +0900 Subject: [PATCH] Add project list page --- doccano/app/db.sqlite3 | Bin 163840 -> 180224 bytes doccano/app/server/admin.py | 3 +- doccano/app/server/models.py | 16 ++-- .../app/server/templates/project_list.html | 74 ++++++++++++++++++ doccano/app/server/tests.py | 9 ++- doccano/app/server/urls.py | 3 +- doccano/app/server/views.py | 14 +++- 7 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 doccano/app/server/templates/project_list.html diff --git a/doccano/app/db.sqlite3 b/doccano/app/db.sqlite3 index f0fca6dada99b03a673968ada7e4a8e50b72f8b8..f4c2b159a91174158592330f20d238dc65a9972c 100644 GIT binary patch delta 4929 zcmc&&Yi!%r73L+Wx20<*c9b>Ea-+s+l-M#!iI(iNbDT$)r=6FRW<{XVA|)}EMVSvb z4|I%NqaD`$Sf&E{vqygg7y=AioIx0Zp}@LgSbqiCh5*g5wM)?gN%rVk1n9P4JCyvc zva~}78}K1`?>*;y=iKieoy+s*{pZgIzP+aHEsCPLX8sX8PhIGWcf3V)-`8F6M&o-R zsV(@Q_})*$KxmY`~R9oN^3$=xQA=NMT z#S$q|!?_$t1LH{(8h5WgC_kKdnOPkt3Twt5vKq6Wlt zN!Ly(88dCcyFst$V4_QA7@VWpX{H;=r=(&|OH1;YT1*$T92X2Q>kx#OuPf7)zMfbo zzCnd%SB|M2i0PSs%juG-YDJ^H@~xhsjo3Gj;DLbH%N+Zxmkzy8;cUo3|8~g!Ivu3S zQOdh681(uEgQd~ugoE_Fr zoJt)$J)Z0ldWI8)gNMws+2N5B+Yg=HeU>{je(cPt+>@qaG;*;p&9F&gzYveb`MzEr zB`etwC&lq@tPoHVosF~Fl&8zRfkZeVsILj{=M$is;Lz_VaD%3SA=y&}CFB?LbGF3d7u~4eUnGpy^+_<7oPZ?+~h74TzOZflBTA z5b9}r&a;ra9!JC+(Ov6&9sRMD;n0n$=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dwQBZ$;pa_15B2{z})E|erhvCdU^SJjE3R0oq zJX!Abl`%AD>O)(ZA(IS|mrTmO(fncJ@kgQ?{ESiRWro$#F;j2{ zN{#+)Qt4Rz0X%gAIY`(=lH>!qNk+&a5+>c`6ggFDY~#uFI++gxnLu6`(2c#i5zA=3 zdL|ajW#SGqtj-B2z^f47rDc=3SYJA6X!&$5J5XIE@jg-8lTXF=Frj%ujm)YM{~Tdx z`{G(&o5Jy}f0bIiFP)8La>?M;Hr!(el0YO;^7L#YX5#!g2aqp_O($dC6ItRL#8lc~ z*JxR}1pU8!SD!+EtMCnZ&}~GTT;o!+bW@zL-*YUknr*MOZN{guo$r^Q%RX+Hr94B+ z2A6o9MR$$hjkZEDWcgOW4C~@@=%$zA@D8lLrSOD)S_bQRdUQ3k0~XJqmFA?-NoTKu ztzefvqlM8HYcvHjm2xd&p?`m^)JCE=*1$S2o27?Xu0;#XFVZ}#qYFNYtOugEr3H@C za3_?2jz>WCsQ5Oj0R@qbt}*$m+*)OmLeArkmyS!0YN2Q!#h8D0C}zn0 z#@gKr*Q`x(*huRxb8o>KOu#Mmu2)szu$tF;Gx~oW`;Ta{`jep8Dm}GMjBxYm`(DTb zF0P#`&`1)tgR@xME|lL}Oj<`YXas*nVzpi11ncJrgU1?l(TgeAG7kq`-;w1Uf<-hk z1g2|n$WOmt1_}5e30T4v*vve2-$es=;FX&XaxX05DdR%!gB*P^4uJ-cDRcw4uX7yd z9>zUxiv8RVBCwj32Nhn!S+XPV6fpDm+FVxOZ-{n`6w;~XbzQWTmmAW3`aUNvXGHTU s-AKqhMh#?5ZfC`raf!od8tK-J0p=eMU=$!xBdKN62P*s8NC(&P8$AB{9{>OV diff --git a/doccano/app/server/admin.py b/doccano/app/server/admin.py index cd1984a0..1cf1bb1a 100644 --- a/doccano/app/server/admin.py +++ b/doccano/app/server/admin.py @@ -1,7 +1,8 @@ from django.contrib import admin -from .models import Annotation, Label, RawData +from .models import Annotation, Label, RawData, Project admin.site.register(Annotation) admin.site.register(Label) admin.site.register(RawData) +admin.site.register(Project) diff --git a/doccano/app/server/models.py b/doccano/app/server/models.py index 3ba9899d..622a6d2f 100644 --- a/doccano/app/server/models.py +++ b/doccano/app/server/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.contrib.auth.models import User class Label(models.Model): @@ -33,13 +34,12 @@ class Annotation(models.Model): 'manual': self.manual} -class User(models.Model): - name = models.CharField(max_length=100) - email = models.EmailField() - password = models.CharField(max_length=32) - # password = forms.CharField(max_length=32, widget=forms.PasswordInput) - - class Project(models.Model): name = models.CharField(max_length=100) - # users = models.ManyToManyField(User) + description = models.TextField() + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + users = models.ManyToManyField(User) + + def __str__(self): + return self.name diff --git a/doccano/app/server/templates/project_list.html b/doccano/app/server/templates/project_list.html new file mode 100644 index 00000000..94d8873c --- /dev/null +++ b/doccano/app/server/templates/project_list.html @@ -0,0 +1,74 @@ +{% extends "base.html" %} +{% load static %} +{% block content %} +
+
+ +
+
+ {% for project in object_list %} +
+

{{ project.name }}

+
+
+

+ +

+
+
+
+

{{ project.description|truncatechars:200 }}

+

+ @jsmith created at {{ project.created_at|date }}   + Question +

+
+
+
+ + 1 +
+
+
+ {% empty %} + No projects yet. + {% endfor %} +
+
+ + +
+ New Project + +
+ +
+
+{% endblock %} \ No newline at end of file diff --git a/doccano/app/server/tests.py b/doccano/app/server/tests.py index 7ce503c2..daee335f 100644 --- a/doccano/app/server/tests.py +++ b/doccano/app/server/tests.py @@ -1,3 +1,10 @@ from django.test import TestCase -# Create your tests here. +from .models import Project + + +class ProjectModelTest(TestCase): + + def test_string_representation(self): + project = Project(name='my project', description='my description') + self.assertEqual(str(project), project.name) diff --git a/doccano/app/server/urls.py b/doccano/app/server/urls.py index 03738dbe..11aa055c 100644 --- a/doccano/app/server/urls.py +++ b/doccano/app/server/urls.py @@ -1,8 +1,9 @@ from django.urls import path -from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI, SearchAPI +from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI, SearchAPI, ProjectListView urlpatterns = [ + path('', ProjectListView.as_view(), name='project-list'), path('/docs', AnnotationView.as_view()), path('/apis/data', AnnotationAPIView.as_view()), path('/apis/label', MetaInfoAPI.as_view()), diff --git a/doccano/app/server/views.py b/doccano/app/server/views.py index b34e7a6a..7fd5538b 100644 --- a/doccano/app/server/views.py +++ b/doccano/app/server/views.py @@ -3,8 +3,9 @@ import json from django.http import JsonResponse from django.shortcuts import render from django.views import View +from django.views.generic.list import ListView -from .models import Annotation, Label, RawData +from .models import Annotation, Label, RawData, Project class AnnotationView(View): @@ -72,3 +73,14 @@ class SearchAPI(View): # Annotation.objects.select_related('data').all().filter(data__text__contains=keyword) return JsonResponse({'data': docs}) + + +class ProjectListView(ListView): + + model = Project + paginate_by = 100 # if pagination is desired + template_name = 'project_list.html' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + return context