mirror of
https://github.com/kristoferssolo/FOSSDB.git
synced 2025-10-21 17:50:35 +00:00
Changed id to uuid
This commit is contained in:
parent
f34cf827c8
commit
f25759bb5b
@ -1,3 +1,5 @@
|
||||
import uuid
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
@ -45,6 +47,7 @@ class ProjectHostingPlatform(models.Model):
|
||||
|
||||
|
||||
class Project(models.Model):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
name = models.CharField(max_length=255, null=False)
|
||||
description = models.TextField()
|
||||
@ -53,5 +56,10 @@ class Project(models.Model):
|
||||
hosting_platform = models.ManyToManyField(HostingPlatform, through="ProjectHostingPlatform", related_name="projects")
|
||||
date_created = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.uuid:
|
||||
self.uuid = uuid.uuid5(uuid.NAMESPACE_URL, f"{self.author.username}-{self.name}")
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.author} | {self.name}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user