This commit is contained in:
Raphael Rouiller
2024-07-08 14:06:52 +02:00
commit aa54287126
96 changed files with 2718 additions and 0 deletions

View File

@ -0,0 +1,4 @@
from .user import CustomUser
from .source import Source
from .tag import Tag
from .suggestion import Suggestion

View File

@ -0,0 +1,17 @@
from django.db import models
from .user import CustomUser
from .tag import Tag
class Source(models.Model):
title = models.CharField(max_length=200)
url = models.URLField()
archived_url = models.URLField()
description = models.TextField()
category = models.CharField(max_length=50)
tags = models.ManyToManyField(Tag, related_name='sources')
added_by = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.title

View File

@ -0,0 +1,12 @@
from django.db import models
from .user import CustomUser
class Suggestion(models.Model):
url = models.URLField()
description = models.TextField()
suggested_by = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True)
created_at = models.DateTimeField(auto_now_add=True)
is_approved = models.BooleanField(default=False)
def __str__(self):
return self.url

View File

@ -0,0 +1,7 @@
from django.db import models
class Tag(models.Model):
name = models.CharField(max_length=50, unique=True)
def __str__(self):
return self.name

View File

@ -0,0 +1,11 @@
from django.contrib.auth.models import AbstractUser
from django.db import models
class CustomUser(AbstractUser):
profile_picture = models.ImageField(upload_to='profile_pics/', blank=True, null=True)
language = models.CharField(max_length=2, default='en')
is_2fa_enabled = models.BooleanField(default=False)
otp_secret = models.CharField(max_length=32, blank=True)
def __str__(self):
return self.username