1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 23:04:21 +00:00

Implement research tags

(closes #52)
This commit is contained in:
Steffo 2021-08-06 21:40:21 +02:00
parent af9d0cbcb6
commit 5d9988899d
Signed by: steffo
GPG key ID: 6965406171929D01
7 changed files with 120 additions and 11 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="sophon" uuid="55182b43-f087-4c24-a13b-f4b7eed545f3">
<data-source source="LOCAL" name="PostgreSQL - sophon" uuid="55182b43-f087-4c24-a13b-f4b7eed545f3">
<driver-ref>postgresql</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.postgresql.Driver</jdbc-driver>

24
backend/poetry.lock generated
View file

@ -42,6 +42,14 @@ sqlparse = ">=0.2.2"
argon2 = ["argon2-cffi (>=19.1.0)"]
bcrypt = ["bcrypt"]
[[package]]
name = "django-colorfield"
version = "0.4.2"
description = "simple color field for your models with a nice color-picker in the admin-interface."
category = "main"
optional = false
python-versions = "*"
[[package]]
name = "django-filter"
version = "2.4.0"
@ -250,7 +258,7 @@ brotli = ["brotlipy (>=0.6.0)"]
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "d569ed4cdb36fab2d02b160c3e8aeb5ecaba83a04841c7c42a5b0d2910761c31"
content-hash = "5414aa8aa7d0a6610e8c65a8686696ae7d40cdc931c9c2e30b61d5e613a17ef8"
[metadata.files]
asgiref = [
@ -269,6 +277,10 @@ django = [
{file = "Django-3.2-py3-none-any.whl", hash = "sha256:0604e84c4fb698a5e53e5857b5aea945b2f19a18f25f10b8748dbdf935788927"},
{file = "Django-3.2.tar.gz", hash = "sha256:21f0f9643722675976004eb683c55d33c05486f94506672df3d6a141546f389d"},
]
django-colorfield = [
{file = "django-colorfield-0.4.2.tar.gz", hash = "sha256:5624a23e2fe97066f45e56eedf9672ab545aa5e52a790cfc33a5f29160a70684"},
{file = "django_colorfield-0.4.2-py3-none-any.whl", hash = "sha256:7f907e11ed053b60d3316199446d76e889caeb27e980fe10cc2d8a825bc84e3a"},
]
django-filter = [
{file = "django-filter-2.4.0.tar.gz", hash = "sha256:84e9d5bb93f237e451db814ed422a3a625751cbc9968b484ecc74964a8696b06"},
{file = "django_filter-2.4.0-py3-none-any.whl", hash = "sha256:e00d32cebdb3d54273c48f4f878f898dced8d5dfaad009438fe61ebdf535ace1"},
@ -295,30 +307,40 @@ lxml = [
{file = "lxml-4.6.3-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:4bff24dfeea62f2e56f5bab929b4428ae6caba2d1eea0c2d6eb618e30a71e6d4"},
{file = "lxml-4.6.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:74f7d8d439b18fa4c385f3f5dfd11144bb87c1da034a466c5b5577d23a1d9b51"},
{file = "lxml-4.6.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:f90ba11136bfdd25cae3951af8da2e95121c9b9b93727b1b896e3fa105b2f586"},
{file = "lxml-4.6.3-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:4c61b3a0db43a1607d6264166b230438f85bfed02e8cff20c22e564d0faff354"},
{file = "lxml-4.6.3-cp35-cp35m-manylinux2014_x86_64.whl", hash = "sha256:5c8c163396cc0df3fd151b927e74f6e4acd67160d6c33304e805b84293351d16"},
{file = "lxml-4.6.3-cp35-cp35m-win32.whl", hash = "sha256:f2380a6376dfa090227b663f9678150ef27543483055cc327555fb592c5967e2"},
{file = "lxml-4.6.3-cp35-cp35m-win_amd64.whl", hash = "sha256:c4f05c5a7c49d2fb70223d0d5bcfbe474cf928310ac9fa6a7c6dddc831d0b1d4"},
{file = "lxml-4.6.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:d2e35d7bf1c1ac8c538f88d26b396e73dd81440d59c1ef8522e1ea77b345ede4"},
{file = "lxml-4.6.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:289e9ca1a9287f08daaf796d96e06cb2bc2958891d7911ac7cae1c5f9e1e0ee3"},
{file = "lxml-4.6.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:bccbfc27563652de7dc9bdc595cb25e90b59c5f8e23e806ed0fd623755b6565d"},
{file = "lxml-4.6.3-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:d916d31fd85b2f78c76400d625076d9124de3e4bda8b016d25a050cc7d603f24"},
{file = "lxml-4.6.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:820628b7b3135403540202e60551e741f9b6d3304371712521be939470b454ec"},
{file = "lxml-4.6.3-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:c47ff7e0a36d4efac9fd692cfa33fbd0636674c102e9e8d9b26e1b93a94e7617"},
{file = "lxml-4.6.3-cp36-cp36m-win32.whl", hash = "sha256:5a0a14e264069c03e46f926be0d8919f4105c1623d620e7ec0e612a2e9bf1c04"},
{file = "lxml-4.6.3-cp36-cp36m-win_amd64.whl", hash = "sha256:92e821e43ad382332eade6812e298dc9701c75fe289f2a2d39c7960b43d1e92a"},
{file = "lxml-4.6.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:efd7a09678fd8b53117f6bae4fa3825e0a22b03ef0a932e070c0bdbb3a35e654"},
{file = "lxml-4.6.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:efac139c3f0bf4f0939f9375af4b02c5ad83a622de52d6dfa8e438e8e01d0eb0"},
{file = "lxml-4.6.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:0fbcf5565ac01dff87cbfc0ff323515c823081c5777a9fc7703ff58388c258c3"},
{file = "lxml-4.6.3-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:36108c73739985979bf302006527cf8a20515ce444ba916281d1c43938b8bb96"},
{file = "lxml-4.6.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:122fba10466c7bd4178b07dba427aa516286b846b2cbd6f6169141917283aae2"},
{file = "lxml-4.6.3-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:cdaf11d2bd275bf391b5308f86731e5194a21af45fbaaaf1d9e8147b9160ea92"},
{file = "lxml-4.6.3-cp37-cp37m-win32.whl", hash = "sha256:3439c71103ef0e904ea0a1901611863e51f50b5cd5e8654a151740fde5e1cade"},
{file = "lxml-4.6.3-cp37-cp37m-win_amd64.whl", hash = "sha256:4289728b5e2000a4ad4ab8da6e1db2e093c63c08bdc0414799ee776a3f78da4b"},
{file = "lxml-4.6.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b007cbb845b28db4fb8b6a5cdcbf65bacb16a8bd328b53cbc0698688a68e1caa"},
{file = "lxml-4.6.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:76fa7b1362d19f8fbd3e75fe2fb7c79359b0af8747e6f7141c338f0bee2f871a"},
{file = "lxml-4.6.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:26e761ab5b07adf5f555ee82fb4bfc35bf93750499c6c7614bd64d12aaa67927"},
{file = "lxml-4.6.3-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:e1cbd3f19a61e27e011e02f9600837b921ac661f0c40560eefb366e4e4fb275e"},
{file = "lxml-4.6.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:66e575c62792c3f9ca47cb8b6fab9e35bab91360c783d1606f758761810c9791"},
{file = "lxml-4.6.3-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:1b38116b6e628118dea5b2186ee6820ab138dbb1e24a13e478490c7db2f326ae"},
{file = "lxml-4.6.3-cp38-cp38-win32.whl", hash = "sha256:89b8b22a5ff72d89d48d0e62abb14340d9e99fd637d046c27b8b257a01ffbe28"},
{file = "lxml-4.6.3-cp38-cp38-win_amd64.whl", hash = "sha256:2a9d50e69aac3ebee695424f7dbd7b8c6d6eb7de2a2eb6b0f6c7db6aa41e02b7"},
{file = "lxml-4.6.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:ce256aaa50f6cc9a649c51be3cd4ff142d67295bfc4f490c9134d0f9f6d58ef0"},
{file = "lxml-4.6.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:7610b8c31688f0b1be0ef882889817939490a36d0ee880ea562a4e1399c447a1"},
{file = "lxml-4.6.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:f8380c03e45cf09f8557bdaa41e1fa7c81f3ae22828e1db470ab2a6c96d8bc23"},
{file = "lxml-4.6.3-cp39-cp39-manylinux2010_i686.whl", hash = "sha256:3082c518be8e97324390614dacd041bb1358c882d77108ca1957ba47738d9d59"},
{file = "lxml-4.6.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:884ab9b29feaca361f7f88d811b1eea9bfca36cf3da27768d28ad45c3ee6f969"},
{file = "lxml-4.6.3-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:6f12e1427285008fd32a6025e38e977d44d6382cf28e7201ed10d6c1698d2a9a"},
{file = "lxml-4.6.3-cp39-cp39-win32.whl", hash = "sha256:33bb934a044cf32157c12bfcfbb6649807da20aa92c062ef51903415c704704f"},
{file = "lxml-4.6.3-cp39-cp39-win_amd64.whl", hash = "sha256:542d454665a3e277f76954418124d67516c5f88e51a900365ed54a9806122b83"},
{file = "lxml-4.6.3.tar.gz", hash = "sha256:39b78571b3b30645ac77b95f7c69d1bffc4cf8c3b157c435a34da72e78c82468"},

View file

@ -14,6 +14,7 @@ django-filter = "^2.4.0"
pandaSDMX = "^1.4.2"
pydantic = "~1.7.3"
django-pam = "^2.0.0"
django-colorfield = "^0.4.2"
[tool.poetry.dev-dependencies]

View file

@ -22,6 +22,20 @@ class ResearchGroupAdmin(CoreAdmin):
)
@admin.register(models.ResearchTag)
class ResearchTagAdmin(CoreAdmin):
list_display = (
"slug",
"name",
"color",
"owner",
)
ordering = (
"slug",
)
@admin.register(models.ResearchProject)
class ResearchProjectAdmin(CoreAdmin):
list_display = (
@ -60,10 +74,6 @@ def sync_flows_admin(modeladmin, request, queryset):
@admin.register(models.DataSource)
class DataSourceAdmin(CoreAdmin):
"""
:class:`.CoreAdmin` class for :class:`.models.DataSource` .
"""
list_display = (
"id",
"name",
@ -134,10 +144,6 @@ class DataSourceAdmin(CoreAdmin):
@admin.register(models.DataFlow)
class DataFlowAdmin(CoreAdmin):
"""
:class:`.CoreAdmin` class for :class:`.models.DataFlow` .
"""
list_display = (
"datasource",
"sdmx_id",

View file

@ -0,0 +1,32 @@
# Generated by Django 3.2 on 2021-08-06 19:18
import colorfield.fields
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('core', '0005_auto_20210806_1506'),
]
operations = [
migrations.CreateModel(
name='ResearchTag',
fields=[
('slug', models.SlugField(help_text='Unique alphanumeric string which identifies the tag.', max_length=64, primary_key=True, serialize=False, verbose_name='Slug')),
('name', models.CharField(help_text='The name of the tag.', max_length=512, verbose_name='Name')),
('description', models.TextField(help_text='Additional information about the tag.', verbose_name='Description')),
('color', colorfield.fields.ColorField(default='#FF7F00', help_text='The color that the tag should have when displayed.', max_length=18, verbose_name='Color')),
('owner', models.ForeignKey(help_text='The user who created the tag, and therefore can delete it.', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.AddField(
model_name='researchproject',
name='tags',
field=models.ManyToManyField(blank=True, help_text='The tags this project has been tagged with.', related_name='tagged', to='core.ResearchTag'),
),
]

View file

@ -8,6 +8,7 @@ import pandasdmx.message
from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
from colorfield import fields as colorfield_models
log = logging.getLogger(__name__)
@ -384,6 +385,45 @@ class ResearchGroup(models.Model):
return f"{self.slug}"
class ResearchTag(models.Model):
"""
A :class:`.ResearchTag` is a keyword that :class:`.ResearchProject`\\ s can be associated with.
"""
slug = models.SlugField(
"Slug",
help_text="Unique alphanumeric string which identifies the tag.",
max_length=64,
primary_key=True,
)
name = models.CharField(
"Name",
help_text="The name of the tag.",
max_length=512,
)
description = models.TextField(
"Description",
help_text="Additional information about the tag.",
)
color = colorfield_models.ColorField(
"Color",
help_text="The color that the tag should have when displayed.",
default="#FF7F00",
)
owner = models.ForeignKey(
User,
help_text="The user who created the tag, and therefore can delete it.",
on_delete=models.CASCADE,
)
def __str__(self):
return f"[{self.name}]"
class ResearchProject(models.Model):
"""
A :class:`.ResearchProject` is a work which may use zero or more :class:`.DataSource`\\ s to prove or disprove an
@ -427,6 +467,13 @@ class ResearchProject(models.Model):
on_delete=models.CASCADE,
)
tags = models.ManyToManyField(
ResearchTag,
help_text="The tags this project has been tagged with.",
related_name="tagged",
blank=True,
)
flows = models.ManyToManyField(
DataFlow,
help_text="The DataFlows used in this project.",
@ -488,4 +535,4 @@ class ResearchProject(models.Model):
return False
def __str__(self):
return f"{self.group.slug}/{self.slug}"
return f"{self.slug}"

View file

@ -40,6 +40,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'django.contrib.postgres',
'rest_framework',
'colorfield',
'sophon.core', # FIXME: Is .apps.CoreConfig not needed?
]