32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
from django.db import models
|
|
from django.utils.text import slugify
|
|
|
|
# Create your models here.
|
|
|
|
class PasswordEntry(models.Model):
|
|
site = models.CharField(max_length=255)
|
|
username = models.CharField(max_length=255)
|
|
password = models.TextField()
|
|
client_id = models.CharField(max_length=255, blank=True)
|
|
topic = models.CharField(max_length=255, blank=True)
|
|
status = models.CharField(max_length=255, blank=True)
|
|
slug = models.SlugField(unique=True, blank=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
def save(self, *args, **kwargs):
|
|
if not self.slug:
|
|
self.slug = slugify(self.username, self.site) # Automatically generate slug from the title
|
|
super().save(*args, **kwargs)
|
|
|
|
class Meta:
|
|
unique_together = ('site', 'username', 'client_id')
|
|
|
|
def __str__(self):
|
|
return self.username
|
|
|
|
class MasterHash(models.Model):
|
|
id = models.CharField(primary_key=True, max_length=10, default="1") # Unica riga con ID fisso
|
|
hash = models.BinaryField() # Hash bcrypt della master password
|
|
|
|
def __str__(self):
|
|
return f"MasterHash(id={self.id})" |