source.py 573 Bytes
Newer Older
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
1
from django.db import models
2
from slugify import slugify
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
3
4
5
6
7


class Source(models.Model):

    name = models.CharField(max_length=100, unique=True, db_index=True)
8
    slug = models.CharField(max_length=100, unique=True, db_index=True)
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
9
10
11
12
    url = models.CharField(max_length=100, blank=True)
    doi = models.CharField(max_length=100, blank=True)
    tools = models.JSONField(blank=True, null=True)

13
14
15
16
    def save(self, *args, **kwargs):
        self.slug=slugify(self.name)
        super(Source, self).save(*args, **kwargs)

Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
17
18
    def __str__(self):
        return f"{self.name}"