Example #1
0
class News(models.Model):

    category=models.ForeignKey(NewsCategory, verbose_name="Мэдээний категори", on_delete=models.CASCADE)
    title=models.CharField(max_length=255, verbose_name="Мэдээний гарчиг(mon)", default='')
    pic=models.ImageField(verbose_name="Мэдээний зураг(mon)", upload_to="news/picture", default="")
    content=CKEditor5Field('Контент(mon)', config_name='extends')
    published_date=models.DateField(verbose_name="Огноо", auto_now=True, editable=False)
    slug=models.CharField(max_length=255, verbose_name="Мэдээний зам", default='', editable=False)
    featured=models.BooleanField(verbose_name="Онцлох мэдээ", default=False)
    viewed=models.IntegerField(editable=False, default=0)
    title_eng=models.CharField(max_length=255, verbose_name="Мэдээний гарчиг(eng)", default='')
    content_eng=CKEditor5Field('Контент(eng)', config_name='extends')

    def __str__(self):
        return self.title
    

    def save(self, *args, **kwargs):
        random_number = randint(1000, 999999999)
        while News.objects.filter(id=random_number).exists():
            random_number = randint(1000, 9999999)
        # self.id = random_number
        
        self.slug = slugify("%s %s" % (self.category.name, str(random_number)))
        super().save(*args, **kwargs)

    class Meta:
        verbose_name = "Мэдээ"
        verbose_name_plural = "Мэдээ"
Example #2
0
class FloorPlan(models.Model):
    floor = models.CharField(max_length=255, verbose_name="Давхар(mon)", null=True, blank=True, default="Оруулаагүй")
    floor_eng = models.CharField(max_length=255, verbose_name="Давхар(eng)", null=True, blank=True, default="Unregistered")
    title = models.CharField(max_length=255, verbose_name="Гарчиг(mon)", null=True, blank=True, default="Оруулаагүй")
    title_eng = models.CharField(max_length=255, verbose_name="Гарчиг(eng)", null=True, blank=True, default="unregistered")
    description = CKEditor5Field('Text(mon)', config_name='extends')
    description_eng = CKEditor5Field('Text(eng)', config_name='extends')
    pic = models.ImageField(upload_to="Home/Plan-Pictures", verbose_name="План зураг", default='settings/index.jpeg', blank=True)


    class Meta:
        verbose_name = 'Давхрын план зураг, танилцуулга'
        verbose_name_plural = 'Давхрын план зураг, танилцуулга'
Example #3
0
class Article(models.Model):
    title = models.CharField(max_length=120, verbose_name='Title')
    text=CKEditor5Field('Text', config_name='extends')
    created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title
Example #4
0
class Empleado(models.Model):
    JOB_CHOICES = (
        ('0', 'CONTADOR'),
        ('1', 'ADMINISTRADOR'),
        ('2', 'ECONOMISTA'),
        ('3', 'OTROS'),
    )

    first_name = models.CharField('Nombres', max_length=60)
    last_name = models.CharField('Apellidos', max_length=60)
    full_name = models.CharField('Nombres Completos',
                                 max_length=120,
                                 blank=True)
    job = models.CharField('Trabajo', max_length=1, choices=JOB_CHOICES)
    avatar = models.ImageField(upload_to='empleado', blank=True, null=True)
    departamento = models.ForeignKey(Departamento, on_delete=models.CASCADE)
    habilidades = models.ManyToManyField(Habilidades)
    hoja_vida = CKEditor5Field('Text', config_name='extends')

    class Meta:
        verbose_name = 'Mis Empleados '
        verbose_name_plural = 'Empleados de la Empresa'
        ordering = ['first_name']
        unique_together = ('first_name', 'departamento')

    def __str__(self):
        return str(self.id) + '-' + self.first_name + '-' + self.last_name
Example #5
0
class Post(models.Model):
    title = models.CharField('Название', max_length=255)
    slug = models.SlugField(max_length=255, verbose_name='Url', unique=True)
    author = models.CharField(max_length=100, verbose_name='Автор')
    content = CKEditor5Field('Содержание', config_name='extends')
    created_at = models.DateTimeField(auto_now_add=True,
                                      verbose_name='Дата добавления')
    photo = models.ImageField(upload_to='photos/%Y/%m/%d',
                              blank=True,
                              verbose_name='Загрузить фото')
    views = models.IntegerField(default=0,
                                verbose_name='Количество просмотров')
    category = models.ForeignKey(Category,
                                 on_delete=models.PROTECT,
                                 related_name='posts',
                                 verbose_name='Категория')
    tags = models.ManyToManyField(Tag,
                                  blank=True,
                                  related_name='posts',
                                  verbose_name='Тэг')

    def __str__(self):
        return self.title

    class Meta:
        ordering = ['-created_at']
        verbose_name = 'Статья'
        verbose_name_plural = 'Статьи'
Example #6
0
class Post(models.Model):
    title = models.CharField(max_length=255, verbose_name='Название')
    slug = models.SlugField(max_length=255, verbose_name='url', unique=True)
    author = models.CharField(max_length=100)
    content = CKEditor5Field('Text', config_name='extends')
    created_at = models.DateTimeField(auto_now_add=True,
                                      verbose_name='Опубликовано')
    photo = models.ImageField(blank=True, default='photo.png')
    views = models.IntegerField(default=0, verbose_name='Кол-во просмотров')
    category = models.ForeignKey(Category,
                                 on_delete=models.PROTECT,
                                 related_name='posts',
                                 verbose_name='Категория')
    tags = models.ManyToManyField(Tag, blank=True, related_name='posts')

    def __str__(self):
        return self.title

    def get_absolute_url(self):  # формирование ссылки
        return reverse('post', kwargs={"slug": self.slug})

    class Meta:
        verbose_name = 'Статью'
        verbose_name_plural = 'Статьи'
        ordering = [
            '-created_at'
        ]  # сортирока по дате в обратном порядке от нового к старому
Example #7
0
class Book(models.Model):
    title = models.CharField(max_length=255)
    link = models.SlugField(max_length=255, unique=True, default='')  # ng usah
    book = models.FileField(upload_to='book/pdf/')  # ng usah
    cover = models.ImageField(upload_to='book/cover/')
    author = models.CharField(max_length=255)
    availability = models.IntegerField(default=0)
    description = CKEditor5Field(null=True, blank=True, config_name='special')
    uploader = models.ForeignKey(User,
                                 on_delete=models.CASCADE,
                                 related_name='uploader')
    pending = models.BooleanField(default=True)  # ng usah
    upload_date = models.DateTimeField(auto_now_add=True)
    likes = models.ManyToManyField(User, related_name='likes', blank=True)
    category = models.ManyToManyField(Category, blank=True)

    def ttl_like(self):
        return self.likes.count()

    def __str__(self):
        return self.title

    def delete(self, *args, **kwargs):
        self.book.delete()
        self.cover.delete()
        super().delete(*args, **kwargs)

    def get_absolute_url(self):
        links = self.link
        links = str(links)
        return reverse('read:detail', args=[links])
class Blog(models.Model):
    title = models.CharField('Title', max_length=200)
    description = CKEditor5Field('description', config_name='extends')
    date = models.DateField()
    image = models.ImageField(upload_to='blog/images/')

    def __str__(self):
        return self.title
Example #9
0
class Comment(models.Model):

    post = models.ForeignKey(Post, on_delete=models.CASCADE)
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    content = CKEditor5Field(config_name='extends', blank=True, null=True)
    release_date = models.DateTimeField(auto_now=True)

    def __str__(self):
        return f'{self.post.title}-{self.user.username}'
class Page(models.Model):
    title = models.CharField(max_length=120,
                             verbose_name='Title',
                             null=False,
                             blank=False)
    content = CKEditor5Field('Content', config_name='extends')
    created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title
Example #11
0
class UserProfile(models.Model):
    user = models.OneToOneField(User, null=True, on_delete=models.CASCADE, related_name='profile')
    profile_image = models.ImageField('Foto Profil Kamu(*opsional)', upload_to='profile/img/', null=True, blank=True)
    name = models.CharField('Nama yang akan kamu daftarkan (Wajib)', max_length=255, null=True)
    phone = models.CharField('Daftarkan Nomor WhatsApp Kamu dengan contoh 813xxxxxxxx', max_length=255, null=True)
    date_created = models.DateTimeField( auto_now_add=True, null=True)
    about_me = CKEditor5Field('Bagikan cerita tentang kamu (*Wajib) walau hanya singkat', config_name='special', default='')

    def __str__(self):
        return str(self.user) + ' as ' + self.name
Example #12
0
class Comment(models.Model):
    book = models.ForeignKey(Book,
                             related_name='comment',
                             on_delete=models.CASCADE)
    name = models.ForeignKey(User, on_delete=models.CASCADE)
    body = CKEditor5Field('Text', null=True, blank=True, config_name='special')
    date_added = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return '%s - %s' % (self.book.title, self.name)
Example #13
0
class Article(models.Model):
    """ Articles for blog. """
    title = models.CharField('Title', max_length=200)
    text = CKEditor5Field("Text", config_name='extends')

    class Meta:
        verbose_name_plural = "Articles"
        verbose_name = "article"

    def __str__(self):
        return self.title
class BaseEvent(AbstractPost):
    """
    A basic event model for groups
    """
    title = models.CharField(max_length=200,
                             verbose_name='Titre de l\'événement')
    description = CKEditor5Field(verbose_name='Description de l\'événement',
                                 blank=True)
    date = models.DateTimeField(verbose_name='Date de l\'événement')
    location = models.CharField(max_length=200, verbose_name='Lieu')
    group = models.SlugField(verbose_name='Groupe organisateur')
    slug = models.SlugField(verbose_name='Slug de l\'événement',
                            unique=True,
                            null=True)
    participants = models.ManyToManyField(to=Student,
                                          verbose_name='Participants',
                                          blank=True)
    ticketing = models.CharField(verbose_name='Lien vers la billeterie',
                                 blank=True,
                                 max_length=200,
                                 null=True)

    @property
    def number_of_participants(self) -> int:
        return self.participants.all().count()

    def is_participating(self, user: User) -> bool:
        student = Student.objects.filter(user=user).first()
        return student in self.participants.all()

    def save(self, *args, **kwargs):
        # create the slug
        self.set_slug(
            f'{self.date.year}-{self.date.month}-{self.date.day}-{self.title}')
        # save the notification
        self.create_notification(title=self.get_group_name,
                                 body=f'Nouvel event : {self.title}')
        # save again the event
        super(BaseEvent, self).save(*args, **kwargs)

    # Don't make this a property, Django expects it to be a method.
    # Making it a property can cause a 500 error (see issue #553).
    def get_absolute_url(self):
        return reverse('event:detail', args=[self.slug])

    @staticmethod
    def get_event_by_slug(slug: str):
        object = get_object_or_404(BaseEvent, slug=slug)
        try:
            object = object.eatingevent
        except EatingEvent.DoesNotExist:
            pass
        return object
Example #15
0
class Post(models.Model):

    title = models.CharField(max_length=100)
    content = CKEditor5Field(config_name='extends', blank=True, null=True)
    date_posted = models.DateTimeField(default=timezone.now)
    author = models.ForeignKey(User, on_delete=models.CASCADE)

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('detail-post', kwargs={'pk': self.pk})
Example #16
0
class Post(models.Model):
    title = models.CharField(max_length=100)
    image = models.ImageField(default='', upload_to='upload')
    genre = models.ForeignKey(Category,
                              default='coding',
                              on_delete=models.CASCADE)
    #content = RichTextField(blank=True, null=True)
    content = CKEditor5Field('Text', config_name='extends')
    date = models.DateTimeField(default=timezone.now)
    author = models.ForeignKey(User, on_delete=models.CASCADE)

    def __str__(self):
        return self.title
Example #17
0
class Article(models.Model):
    """ Articles for blog. """
    title = models.CharField('Title', max_length=200)
    text = CKEditor5Field("Text", config_name='extends')
    image = models.ImageField(upload_to='ckeditor_test_app/images',
                              null=True,
                              blank=True)

    class Meta:
        verbose_name_plural = "Articles"
        verbose_name = "article"

    def __str__(self):
        return self.title
Example #18
0
class Post(models.Model):
    author = models.ForeignKey(settings.AUTH_USER_MODEL,
                               on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    text = CKEditor5Field('Text', config_name='extends')
    created_date = models.DateTimeField(default=timezone.now)
    published_date = models.DateTimeField(blank=True, null=True)

    def publish(self):
        self.published_date = timezone.now()
        self.save()

    def __str__(self):
        return self.title
Example #19
0
class Term(models.Model):
    created = models.DateTimeField(auto_now_add=True, editable=False)
    modified = models.DateTimeField(auto_now=True, editable=False)
    title = models.CharField(max_length=250)
    slug = models.SlugField(unique=True)
    description = CKEditor5Field('Text', config_name='extends')

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('django_glossary:term-detail',
                       kwargs={'slug': self.slug})

    class Meta:
        ordering = ['title', '-modified']
Example #20
0
class News(Base, Keyword):
    keywords_fields = [
        'title',
    ]
    title = models.CharField(max_length=255)
    news = CKEditor5Field(blank=True, null=True)
    date_news = models.DateField(blank=True, null=True)

    class Meta(Base.Meta):
        abstract = True
        ordering = [
            'date_news',
        ]

    def __str__(self):
        return "%s - %s" % (str(self.date_news), self.title)
Example #21
0
class Post(models.Model):
    title = models.CharField(max_length=100)
    content = CKEditor5Field(blank=True, null=True, config_name='extends')
    # content = models.TextField()
    date_posted = models.DateTimeField(default=timezone.now)
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    snippet = models.CharField(blank=True, max_length=100)
    category = models.CharField(max_length=100, default='uncategorised')
    likes = models.ManyToManyField(User, related_name='blogpost_like')

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('blog-home')

    def number_of_likes(self):
        return self.likes.count()
Example #22
0
class GuidePost(models.Model):
    title = models.CharField(verbose_name=_("Title"),
                             help_text=_("Please enter the title of the Post"),
                             max_length=70)
    slug = models.SlugField(
        help_text=_("Slug consisting of title of guide post."),
        unique=True,
        null=False,
        default="guidePost")
    author = models.ForeignKey("exchangeblog.BlogAuthor",
                               verbose_name=_("Author"),
                               on_delete=models.SET_NULL,
                               null=True)
    guide_content = CKEditor5Field(
        config_name='blogpost-editor',
        verbose_name=_("Guide content"),
        help_text=_("Here is the place to write the actual guide itself."))
    short_description = models.TextField(
        verbose_name=_("Short description"),
        help_text=_(
            "Enter a short description about what this tutorial is about."),
        max_length=250)
    thumbnail_picture = ProcessedImageField(
        verbose_name=_("Thumbnail picture"),
        upload_to='guide_thumbnails/',
        processors=[ResizeToFill(500, 300)],
        options={'quality': 80},
        max_length=100)
    main_guide_post_number = models.IntegerField(
        verbose_name=_("Main Guide Post Number"),
        help_text=
        _("If post is part of the main step by step guide, enter its number in the order here."
          ),
        unique=True,
        blank=True,
        null=True)

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse("guide-detail", kwargs={"slug": self.slug})
Example #23
0
class Item(models.Model):
    title = models.CharField(max_length=100)
    slug = AutoSlugField(max_length=255, verbose_name='url', unique=True, populate_from='title')
    price = models.FloatField(default=0.0)
    description = models.TextField(max_length=2000)
    characteristics = CKEditor5Field('Characteristics')
    image = models.ImageField(default="default1.jpg")
    category = models.ManyToManyField(Category, related_name='item')

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('core:product', kwargs={"slug": self.slug})

    def get_add_to_cart_url(self):
        return reverse('core:add-to-cart', kwargs={"slug": self.slug})

    def get_remove_from_cart_url(self):
        return reverse('core:remove-from-cart', kwargs={"slug": self.slug})
Example #24
0
class SubPage(models.Model):
    page_title = models.CharField(max_length=255, verbose_name="Хуудас гарчиг(mon)", null=True,  default="")
    page_title_eng = models.CharField(max_length=255, verbose_name="Хуудас гарчиг(eng)", null=True,  default="")
    lefty_title = models.CharField(max_length=255, verbose_name="Зүүн зурагтай - Гарчиг(mon)", null=True, blank=True, default="Оруулаагүй")
    lefty_title_eng = models.CharField(max_length=255, verbose_name="Зүүн зурагтай - Гарчиг(eng)", null=True, blank=True, default="Unregistered")
    lefty_description = CKEditor5Field('Text(mon)', config_name='extends', blank=True)
    lefty_description_eng = CKEditor5Field('Text(eng)', config_name='extends', blank=True)
    lefty_pic = models.ImageField(upload_to="Sub-pages/about-us", verbose_name="Зүүн зурагтай - зураг", default='settings/index.jpeg', blank=True)

    notitledicon_left_title = models.CharField(max_length=255, verbose_name="NoTitledIcon left - Гарчиг(mon)", null=True, blank=True, default="Оруулаагүй")
    notitledicon_left_title_eng = models.CharField(max_length=255, verbose_name="NoTitledIcon left - Гарчиг(eng)", null=True, blank=True, default="Unregistered")
    notitledicon_left_description = CKEditor5Field('Text(mon)', config_name='extends', blank=True)
    notitledicon_left_description_eng = CKEditor5Field('Text(eng)', config_name='extends', blank=True)

    righty_title = models.CharField(max_length=255, verbose_name="Баруун зурагтай - Гарчиг(mon)", null=True, blank=True, default="Оруулаагүй")
    righty_title_eng = models.CharField(max_length=255, verbose_name="Баруун зурагтай - Гарчиг(eng)", null=True, blank=True, default="Unregistered")
    righty_description = CKEditor5Field('Text(mon)', config_name='extends', blank=True)
    righty_description_eng = CKEditor5Field('Text(eng)', config_name='extends', blank=True)
    righty_pic = models.ImageField(upload_to="Sub-pages/about-us", verbose_name="Баруун зурагтай - зураг", default='settings/index.jpeg', blank=True)
 
    
    notitledicon_right_title = models.CharField(max_length=255, verbose_name="NoTitledIcon right - Гарчиг(mon)", null=True, blank=True, default="Оруулаагүй")
    notitledicon_right_title_eng = models.CharField(max_length=255, verbose_name="NoTitledIcon right - Гарчиг(eng)", null=True, blank=True, default="Оруулаагүй")
    notitledicon_right_description = CKEditor5Field('Text(mon)', config_name='extends', blank=True)
    notitledicon_right_description_eng = CKEditor5Field('Text(eng)', config_name='extends', blank=True)

    righty_pic = models.ImageField(upload_to="Sub-pages/about-us", verbose_name="Зураг том", default='settings/index.jpeg', blank=True)
    
    sign = models.CharField(max_length=255, null=True,  default="", editable=False)

    def __str__(self):
        return self.page_title

    class Meta:
        verbose_name = 'Дэд хуудас'
        verbose_name_plural = 'Дэд хуудас'
Example #25
0
class Empleado(models.Model):
    """Modelo para tabla empleado"""

    JOB_CHOICES = (
        ('0', 'CONTADOR'),
        ('1', 'ADMINISTRADOR'),
        ('2', 'ECONOMISTA'),
        ('3', 'OTRO'),
    )

    #Contador
    #Administrador
    #Economista
    #otro
    first_name = models.CharField('Nombres', max_length=60)
    last_name = models.CharField('Apellidos', max_length=60)
    full_name = models.CharField(
        'Nombres completos',
         max_length=120,
         blank=True
         )
    job = models.CharField('Trabajo', max_length=50, choices=JOB_CHOICES)
    departamento = models.ForeignKey(Departamento, on_delete=models.CASCADE)
    avatar = models.ImageField(upload_to='empleado', blank=True, null=True)
    habilidades = models.ManyToManyField(Habilidades)
    hoja_vida =CKEditor5Field('Hoja de Vida')
 


    class  Meta:
        verbose_name = 'Mis empleados'
        verbose_name_plural = 'Empleados de la empresa'
        ordering = ['first_name']
        unique_together = ('first_name','last_name')


    def __str__(self):
        return str(self.id) + '-' + self.first_name + '-' + self.last_name
Example #26
0
class Post(models.Model):
    title = models.CharField(max_length=255, verbose_name='Название')
    # slug = models.SlugField(max_length=255, verbose_name='url', unique=True)
    slug = AutoSlugField(populate_from='title')
    user = models.ForeignKey(User,
                             on_delete=models.CASCADE,
                             verbose_name='Пользователь',
                             null=True)
    content = CKEditor5Field('Text', config_name='extends')
    created_at = models.DateTimeField(auto_now_add=True,
                                      verbose_name='Опубликовано')
    photo = models.ImageField(blank=True,
                              default='blog-1.jpg',
                              verbose_name='Фото',
                              upload_to='post_pics')
    views = models.IntegerField(default=0, verbose_name='Кол-во просмотров')
    category = models.ManyToManyField(Category, related_name='posts')
    tags = models.ManyToManyField(Tag,
                                  blank=True,
                                  related_name='posts',
                                  verbose_name='Тег')

    def __str__(self):
        return self.title

    def get_absolute_url(self):  # формирование ссылки 'posts' - name in urls
        return reverse('post', kwargs={"slug": self.slug})

    @property
    def get_comments(self):
        return self.comments.all()

    class Meta:
        verbose_name = 'Статью'
        verbose_name_plural = 'Статьи'
        ordering = [
            '-created_at'
        ]  # сортирока по дате в обратном порядке от нового к старому
Example #27
0
class Youtuber(models.Model):

    crew_choices = (
        ('solo', 'solo'),
        ('small', 'small'),
        ('large', 'large'),
    )

    camera_choices = (
        ('sony', 'sony'),
        ('nikon', 'nikon'),
        ('canon', 'canon'),
    )

    category_choices = (
        ('coding', 'coding'),
        ('gaming', 'gaming'),
        ('cooking', 'cooking'),
        ('comedy', 'comedy'),
        ('Tech reviews', 'Tech reviews'),
        ('Vlogs', 'Vlogs'),
    )

    name = models.CharField(max_length=255)
    price = models.IntegerField()
    photo = models.ImageField(upload_to='media/ytubers/%y/%m')
    video_url = models.CharField(max_length=255)
    description = CKEditor5Field()
    city = models.CharField(max_length=255)
    age = models.CharField(max_length=255)
    height = models.IntegerField()
    crew = models.CharField(choices=crew_choices, max_length=255)
    camera_type = models.CharField(choices=camera_choices, max_length=255)
    subs_count = models.IntegerField()
    category = models.CharField(choices=category_choices, max_length=255)
    is_featured = models.BooleanField(default=False)
    created_date = models.DateTimeField(auto_now_add=True)
Example #28
0
class Post(models.Model):
    title = models.CharField(max_length=255)
    header_image = models.ImageField(null=True,
                                     blank=True,
                                     upload_to="images/")
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    #body = models.TextField()
    #body = CKEditor5Field('Text', config_name='extends')
    body = CKEditor5Field('Text', config_name='extends', blank=True)
    post_date = models.DateTimeField(auto_now_add=True, editable=False)
    update_date = models.DateTimeField(blank=True, null=True)
    likes = models.ManyToManyField(User, related_name='blog_posts')
    saved = models.ManyToManyField(User, related_name='save_posts')
    hit_count_generic = GenericRelation(
        HitCount,
        object_id_field='object_pk',
        related_query_name='hit_count_generic_relation')
    #slug = models.SlugField(max_length=255, blank=True,null=True)
    tags = TaggableManager()

    def total_likes(self):
        return self.likes.count()

    def liked_by(self):
        return self.likes.all()

    def __str__(self):
        return self.title + ' | ' + str(self.author)

    def get_absolute_url(self):
        #return reverse('post_details', args=(str(self.id)))
        return reverse('home')

    def update(self, *args, **kwargs):
        kwargs.update({'update_date': timezone.now})
        #super().update(*args, **kwargs)
        return self
Example #29
0
class Post(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,default=1,on_delete=models.CASCADE)    
    title = models.CharField(max_length=400)
    slug = models.SlugField(unique=True)
    email = models.EmailField()
    content = CKEditor5Field(blank=True,null=True)
    likes = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name="likes", blank=True)
    updated = models.DateTimeField(auto_now=True,auto_now_add=False)
    timestamp = models.DateTimeField(auto_now=False,auto_now_add=True)
    draft = models.BooleanField(default=False)
    tags = TaggableManager(blank=True)
    categories = models.ForeignKey(Categories,blank=True,null=True,on_delete=models.CASCADE)
    countlikes = models.IntegerField(blank=True,null=True)
    def __unicode__(self):
        return self.title
    def __str__(self):
        return self.slug

    def get_absolute_url(self):
        return "/%s/post-detail/" %(self.slug)
    def total_likes(self):
        return self.likes.count()
    class Meta:
        ordering = ["-timestamp","-updated"] 
class Group(models.Model, SlugModel):
    '''Modèle abstrait servant de modèle pour tous les types de Groupes.'''

    # Nom du groupe
    name = models.CharField(verbose_name='Nom du groupe',
                            unique=True,
                            max_length=100)
    alt_name = models.CharField(verbose_name='Nom alternatif',
                                max_length=100,
                                null=True,
                                blank=True)

    # présentation
    logo = models.ImageField(
        verbose_name='Logo du groupe',
        blank=True,
        null=True,
        upload_to=path_and_rename_group,
        help_text="Votre logo sera affiché au format 306x306 pixels.")
    banniere = models.ImageField(
        verbose_name='Bannière',
        blank=True,
        null=True,
        upload_to=path_and_rename_group_banniere,
        help_text="Votre bannière sera affichée au format 1320x492 pixels.")
    summary = models.CharField('Résumé', max_length=500, null=True, blank=True)
    description = CKEditor5Field(verbose_name='Description du groupe',
                                 blank=True)
    video1 = models.URLField('Lien vidéo 1',
                             max_length=200,
                             null=True,
                             blank=True)
    video2 = models.URLField('Lien vidéo 2',
                             max_length=200,
                             null=True,
                             blank=True)

    # paramètres techniques
    members = models.ManyToManyField(Student,
                                     verbose_name='Membres du groupe',
                                     related_name='%(class)s_members',
                                     through='NamedMembership')
    slug = models.SlugField(max_length=40, unique=True, blank=True)
    modified_date = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True

    def __str__(self):
        return self.name

    def is_admin(self, user: User) -> bool:
        """Indicates if a user is admin."""
        if user.is_anonymous or not user.is_authenticated or not hasattr(
                user, 'student'):
            return False
        student = Student.objects.filter(user=user).first()
        if user.is_superuser:
            return True
        if self.is_member(user):
            members_list = self.members.through.objects.filter(group=self)
            my_member = members_list.filter(student=student).first()
            return my_member.admin
        return False

    def is_member(self, user: User) -> bool:
        """Indicates if a user is member."""
        if user.is_anonymous or not user.is_authenticated or not hasattr(
                user, 'student'):
            return False
        return user.student in self.members.all()

    def save(self, *args, **kwargs):
        # cration du slug si non-existant ou corrompu
        self.set_slug(self.name, 40)
        # compression des images
        self.logo = compressModelImage(self,
                                       'logo',
                                       size=(500, 500),
                                       contains=True)
        self.banniere = compressModelImage(self,
                                           'banniere',
                                           size=(1320, 492),
                                           contains=False)
        # enregistrement
        super(Group, self).save(*args, **kwargs)

    @property
    def app(self):
        return self._meta.app_label

    @property
    def full_slug(self):
        return f'{self.app}--{self.slug}'

    @property
    def app_name(self):
        return self.modelName.title()

    # Don't make this a property, Django expects it to be a method.
    # Making it a property can cause a 500 error (see issue #553).
    def get_absolute_url(self):
        return reverse(self.app + ':detail', kwargs={'slug': self.slug})

    @property
    def modelName(self):
        '''Plural Model name, used in templates'''
        return self.__class__._meta.verbose_name_plural