Skip to content

Commit 781cbc5

Browse files
committed
Models created: User, Project, Annotation, Comment, Label, Task
1 parent e744bc7 commit 781cbc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+792
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bin/
2+
lib/
3+
*.pyc

label_buddy/annotations/__init__.py

Whitespace-only changes.

label_buddy/annotations/admin.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.contrib import admin
2+
3+
#relative import
4+
from .models import Comment, Annotation
5+
6+
admin.site.register(Comment)
7+
admin.site.register(Annotation)

label_buddy/annotations/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AnnotationsConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'annotations'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Generated by Django 3.2.3 on 2021-06-03 10:48
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
initial = True
10+
11+
dependencies = [
12+
('users', '0001_initial'),
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='Comment',
18+
fields=[
19+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('comment', models.TextField(help_text='Comment for an annotation')),
21+
('created_at', models.DateTimeField(auto_now=True, help_text='Date and time of comment creation')),
22+
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.user')),
23+
],
24+
),
25+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generated by Django 3.2.3 on 2021-06-03 10:49
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('tasks', '0001_initial'),
11+
('users', '0001_initial'),
12+
('projects', '0001_initial'),
13+
('annotations', '0001_initial'),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name='Annotation',
19+
fields=[
20+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21+
('created_at', models.DateTimeField(auto_now=True, help_text='Date and time of annotation creation')),
22+
('updated_at', models.DateTimeField(help_text='Date and time of update')),
23+
('result', models.JSONField()),
24+
('reviewed_at', models.DateTimeField(blank=True, help_text='Date and time of a review')),
25+
('rejected_by_user', models.BooleanField(default=False)),
26+
('hidden_by_user', models.BooleanField(default=False)),
27+
('comment', models.ManyToManyField(blank=True, related_name='annotation_comment', to='annotations.Comment')),
28+
('project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='projects.project')),
29+
('reviewed_by', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='annotation_reviewer', to='users.user')),
30+
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.task')),
31+
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='annotation_user', to='users.user')),
32+
],
33+
),
34+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.3 on 2021-06-03 10:57
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('annotations', '0002_annotation'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='annotation',
15+
name='result',
16+
field=models.JSONField(null=True),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.3 on 2021-06-03 10:59
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('annotations', '0003_alter_annotation_result'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='annotation',
15+
name='result',
16+
field=models.JSONField(blank=True, null=True),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.2.3 on 2021-06-03 11:00
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('annotations', '0004_alter_annotation_result'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='annotation',
15+
name='reviewed_at',
16+
field=models.DateTimeField(blank=True, help_text='Date and time of a review', null=True),
17+
),
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Django 3.2.3 on 2021-06-03 11:01
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('users', '0001_initial'),
11+
('annotations', '0005_alter_annotation_reviewed_at'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='annotation',
17+
name='reviewed_by',
18+
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='annotation_reviewer', to='users.user'),
19+
),
20+
]

label_buddy/annotations/migrations/__init__.py

Whitespace-only changes.

label_buddy/annotations/models.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from django.db import models
2+
3+
from users.models import User
4+
from tasks.models import Task
5+
from projects.models import Project
6+
7+
# Create your models here.
8+
9+
class Comment(models.Model):
10+
11+
'''
12+
Comment class for comments done by reviewers
13+
Annotators will be able to see the comments on their annotations
14+
'''
15+
16+
comment = models.TextField(blank=False, help_text='Comment for an annotation')
17+
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=False)
18+
created_at = models.DateTimeField(auto_now=True, help_text='Date and time of comment creation')
19+
20+
21+
class Annotation(models.Model):
22+
23+
'''
24+
Annotation class for annotations done by annotators
25+
Annotation format will be in JSON format
26+
'''
27+
28+
task = models.ForeignKey(Task, on_delete=models.CASCADE, blank=False) #task to which the annotation belongs
29+
project = models.ForeignKey(Project, on_delete=models.CASCADE, blank=False) #project to which the annotation belongs
30+
user = models.ForeignKey(User, on_delete=models.CASCADE, blank=False, related_name='annotation_user') #user who annotated
31+
32+
created_at = models.DateTimeField(auto_now=True, help_text='Date and time of annotation creation')
33+
updated_at = models.DateTimeField(blank=False, help_text='Date and time of update')
34+
35+
result = models.JSONField(blank=True, null=True)
36+
37+
reviewed_by = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True, related_name='annotation_reviewer')
38+
reviewed_at = models.DateTimeField(blank=True, null=True, help_text='Date and time of a review')
39+
40+
rejected_by_user = models.BooleanField(default=False)
41+
hidden_by_user = models.BooleanField(default=False)
42+
43+
comment = models.ManyToManyField(Comment, blank=True, related_name='annotation_comment')
44+

label_buddy/annotations/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

label_buddy/annotations/views.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

label_buddy/db.sqlite3

308 KB
Binary file not shown.

label_buddy/label_buddy/__init__.py

Whitespace-only changes.

label_buddy/label_buddy/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for label_buddy project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'label_buddy.settings')
15+
16+
application = get_asgi_application()

label_buddy/label_buddy/settings.py

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
"""
2+
Django settings for label_buddy project.
3+
4+
Generated by 'django-admin startproject' using Django 3.2.3.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.2/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.2/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'django-insecure-!(7v*kvxyuj+ldou)*6xy5)a%w*z=0&_%yw$t9l0e^oxo50*+-'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
41+
#third party
42+
'colorfield',
43+
'url_or_relative_url_field',
44+
45+
#own
46+
'users',
47+
'projects',
48+
'tasks',
49+
'annotations',
50+
]
51+
52+
MIDDLEWARE = [
53+
'django.middleware.security.SecurityMiddleware',
54+
'django.contrib.sessions.middleware.SessionMiddleware',
55+
'django.middleware.common.CommonMiddleware',
56+
'django.middleware.csrf.CsrfViewMiddleware',
57+
'django.contrib.auth.middleware.AuthenticationMiddleware',
58+
'django.contrib.messages.middleware.MessageMiddleware',
59+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
60+
]
61+
62+
ROOT_URLCONF = 'label_buddy.urls'
63+
64+
TEMPLATES = [
65+
{
66+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
67+
'DIRS': [],
68+
'APP_DIRS': True,
69+
'OPTIONS': {
70+
'context_processors': [
71+
'django.template.context_processors.debug',
72+
'django.template.context_processors.request',
73+
'django.contrib.auth.context_processors.auth',
74+
'django.contrib.messages.context_processors.messages',
75+
],
76+
},
77+
},
78+
]
79+
80+
WSGI_APPLICATION = 'label_buddy.wsgi.application'
81+
82+
83+
# Database
84+
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
85+
86+
DATABASES = {
87+
'default': {
88+
'ENGINE': 'django.db.backends.sqlite3',
89+
'NAME': BASE_DIR / 'db.sqlite3',
90+
}
91+
}
92+
93+
94+
# Password validation
95+
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
96+
97+
AUTH_PASSWORD_VALIDATORS = [
98+
{
99+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
100+
},
101+
{
102+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
103+
},
104+
{
105+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
106+
},
107+
{
108+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
109+
},
110+
]
111+
112+
113+
# Internationalization
114+
# https://docs.djangoproject.com/en/3.2/topics/i18n/
115+
116+
LANGUAGE_CODE = 'en-us'
117+
118+
TIME_ZONE = 'UTC'
119+
120+
USE_I18N = True
121+
122+
USE_L10N = True
123+
124+
USE_TZ = True
125+
126+
127+
# Static files (CSS, JavaScript, Images)
128+
# https://docs.djangoproject.com/en/3.2/howto/static-files/
129+
130+
STATIC_URL = '/static/'
131+
132+
# Default primary key field type
133+
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
134+
135+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

label_buddy/label_buddy/urls.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""label_buddy URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.2/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path
18+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
]

0 commit comments

Comments
 (0)