Beispiel #1
0
class Post(models.Model):
    title = models.CharField(max_length=100)
    overview = models.TextField()
    timestamp = models.DateTimeField(auto_now_add=True)
    # comment_count = models.IntegerField(default=0)
    content = HTMLField('Content')
    # view_count = models.IntegerField(default=0)
    thumbnail = models.ImageField()
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    categories = models.ManyToManyField(Category)
    featured = models.BooleanField()
    previous_post = models.ForeignKey(
        'self', related_name='previous', on_delete=models.SET_NULL, null=True, blank=True)
    next_post = models.ForeignKey(
        'self', related_name='next', on_delete=models.SET_NULL, null=True, blank=True)

    def __str__(self):
        return self.title

    def summary(self):
        if len(self.overview) > 300:
            return self.overview[:300] + ' . . .'
        return self.overview

    def get_absolute_url(self):
        return reverse('post-detail', kwargs={
            'id': self.id
        })

    def get_update_url(self):
        return reverse('post-update', kwargs={
            'id': self.id
        })

    def get_delete_url(self):
        return reverse('post-delete', kwargs={
            'id': self.id
        })

    @property
    def get_comments(self):
        return self.comments.all().order_by('-timestamp')

    @property
    def view_count(self):
        return PostView.objects.filter(post=self).count()

    @property
    def comment_count(self):
        return Comment.objects.filter(post=self).count()
class Post(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    date = models.DateTimeField(auto_now_add=True)
    title = models.TextField(max_length=255)
    description = HTMLField('Description')
    image = models.ImageField(upload_to="Post_images",
                              default='media/default.png')
    category = models.ForeignKey(Category, on_delete=models.CASCADE)

    def get_absolute_url(self):
        return reverse('posts:all')

    def __str__(self):
        return self.title
Beispiel #3
0
class Post(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255, unique=True)
    banner = models.ImageField(upload_to='blog/post_banner')
    post = HTMLField('Post')
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    published = models.BooleanField(default=True)
    view = models.IntegerField(default=0)

    def __str__(self):
        return self.title
Beispiel #4
0
class Screening(models.Model):
    name = models.CharField(
        max_length=100,
        help_text="Only if the screening needs a special title",
        blank=True,
    )
    film = models.ForeignKey(Film, null=True, on_delete=models.CASCADE)
    venue = models.ForeignKey(Venue, null=True, on_delete=models.CASCADE)
    season = models.ForeignKey(Season,
                               blank=True,
                               null=True,
                               on_delete=models.CASCADE)
    programme = models.ForeignKey(Programme,
                                  null=True,
                                  on_delete=models.CASCADE)
    date = models.DateField()
    start_time = models.TimeField()
    tickets = models.URLField(max_length=100,
                              help_text="Link to external tickets page",
                              blank=True,
                              null=True)
    subtitle = models.CharField(
        max_length=100,
        help_text="Only if the screening needs a special subtitle",
        blank=True,
    )
    copy = HTMLField("Text",
                     help_text="Only if the screening needs special copy",
                     blank=True)
    q_and_a = models.BooleanField(blank=True)
    introduction = models.BooleanField(blank=True)
    subtitled = models.BooleanField(blank=True)
    audio_description = models.BooleanField(blank=True)
    relaxed_environment = models.BooleanField(blank=True)
    dementia_friendly = models.BooleanField(blank=True)
    pinned = models.BooleanField(
        default=False,
        help_text="If you want to pin the screening to the front page")

    def __str__(self):
        return str(self.id)

    def get_absolute_url(self):
        kwargs = {"pk": self.pk}
        return reverse("screening-detail", kwargs=kwargs)

    def screening_passed(self):
        todaysdate = datetime.now().date()
        if self.date < todaysdate:
            return True
Beispiel #5
0
class Blog(models.Model):
    language = models.ForeignKey(Language, on_delete=models.SET_NULL, blank=True, null=True)
    title = models.CharField(max_length=100)
    content = HTMLField('Content') # Texte central
    overview = models.TextField() # Texto en el separador
    title_last_posts = models.CharField(max_length=100,default="Title")
    description_last_posts = models.TextField(default="last posts")
    title_newsletter = models.CharField(max_length=100, default="title")
    description_news_letter=models.TextField(default="Newsletter text")
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    timestamp = models.DateField(auto_now_add=True)

    def __str__(self):
        return self.title
Beispiel #6
0
class Project(models.Model):
    title = models.CharField(max_length=250)
    project_text = HTMLField('Project Text')
    frontend_dev = models.CharField(max_length=250, default='')
    backend_dev = models.CharField(max_length=250, default='')
    image = models.ImageField(upload_to='media/uploads',
                              default='media/uploads/no-img.jpg')
    pub_date = models.DateTimeField('date published')
    author = models.ForeignKey(User,
                               related_name='project_author',
                               on_delete=models.CASCADE)

    def __str__(self):
        return self.title
Beispiel #7
0
class Letters(models.Model):
    title = models.CharField(max_length=100, blank=True, null=True)
    content = HTMLField(max_length=2000, blank=True, null=True)
    timestamp = models.DateTimeField(auto_now_add=True)
    image = models.ImageField(upload_to='admission/', blank=True, null=True)
    news_letter = models.FileField(upload_to='letters/', blank=True)


    class Meta:
        verbose_name = 'admission'
        verbose_name_plural = 'admission'

    def __str__(self):
        return self.title
Beispiel #8
0
class Post(models.Model):
    author = models.ForeignKey(settings.AUTH_USER_MODEL,
                               on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    content = HTMLField()
    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
Beispiel #9
0
class VideoCollection(models.Model):
    title = models.CharField(max_length=255)
    description = HTMLField('description', null=True, blank=True)
    site = models.ForeignKey(Site, on_delete=models.CASCADE, default=settings.SITE_ID)
    position = models.PositiveSmallIntegerField(default=1)
    objects = models.Manager()
    on_site = CurrentSiteManager()
    show_in_list = models.BooleanField(default=True)

    def __str__(self):
        return self.title

    class Meta:
        ordering = ["position"]
Beispiel #10
0
class Article(models.Model):
    owner = models.ForeignKey(User, on_delete=models.CASCADE)
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    title = models.CharField(max_length=100, unique=True)
    subtitle = models.CharField(max_length=200)
    text = HTMLField()
    date_created = models.DateTimeField(auto_now_add=True)

    class Meta:
        ordering = ['-date_created']
        get_latest_by = ['-date_created']

    def __str__(self):
        return self.title
Beispiel #11
0
class Admisssion(models.Model):
    content = HTMLField('Content')
    note = models.IntegerField()

    date_add = models.DateField(auto_now_add=True)
    date_update = models.DateField(auto_now_add=True)
    status = models.BooleanField(default=True)

    class Meta:
        verbose_name = ("Admisssion")
        verbose_name_plural = ("Admisssions")

    def __str__(self):
        return str(self.note)
Beispiel #12
0
class Student_Notes(models.Model):
    """Allow Staff to record various information/remarks/comments about a student.
	   Notes are non public nor private as the head of the school should be able to access them if need be
	"""

    __tablename__ = 'Student Notes'

    uuid = models.UUIDField(primary_key=True,
                            default=uuid.uuid4,
                            editable=False)
    title = models.CharField(max_length=100, null=True, blank=True)
    content = HTMLField(_('Content'), null=True, blank=True)
    note_category = models.ForeignKey(to='Note_Category',
                                      related_name='note_category',
                                      on_delete=models.SET_NULL,
                                      null=True,
                                      blank=True)
    student = models.ForeignKey(Student,
                                related_name='student_have_note',
                                on_delete=models.CASCADE,
                                null=False,
                                blank=False)

    comment = models.CharField(max_length=255, null=True,
                               blank=True)  # Free text
    created_at = models.DateTimeField(editable=False,
                                      auto_now_add=True,
                                      auto_now=False,
                                      null=True,
                                      blank=True)  # Creation TIMESTAMP
    updated_at = models.DateTimeField(editable=False,
                                      auto_now_add=False,
                                      auto_now=True,
                                      null=True,
                                      blank=True)  # Last update TIMESTAMP
    creator = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        on_delete=models.CASCADE,
        related_name='creator_student_note')  # Creator username

    def __str__(self):
        return '{} - {}'.format(self.note_category, self.title)

    class Meta:
        ordering = (
            '-created_at',
            '-updated_at',
        )
        verbose_name = _('Student Note')
        verbose_name_plural = _('Student Notes')
Beispiel #13
0
class Post(models.Model):
    title = models.CharField(max_length=200, db_index=True)
    preview = HTMLField(blank=True, max_length=200, db_index=True)
    content = HTMLField(blank=True, max_length=2000, db_index=True)
    author = models.CharField(max_length=200)
    pub_date = models.DateTimeField(auto_now_add=True)
    category = models.ForeignKey('Category',
                                 blank=True,
                                 null=True,
                                 on_delete=models.CASCADE)
    tags = models.ManyToManyField('Tag', blank=True, related_name='posts')

    def get_detail_url(self):
        return reverse('blog:post_detail_url', kwargs={'pk': self.pk})

    def get_add_comment_url(self):
        return reverse('blog:add_comment_url', kwargs={'pk': self.pk})

    def __str__(self):
        return self.title

    class Meta:
        ordering = ['-pub_date']
Beispiel #14
0
class Post(models.Model):
    title = models.CharField(max_length=200)
    description = models.CharField(max_length=200)
    content = HTMLField()
    date = models.DateTimeField(auto_now_add=True)
    author = models.ForeignKey(Author, on_delete=models.CASCADE)
    thumbnail = models.ImageField(null=True, blank=True)
    featured = models.BooleanField()

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('blog', kwargs={'blog_id': self.id})
Beispiel #15
0
class Capitulo(models.Model):
    capitulo = models.CharField(max_length=10)
    titulo = models.CharField(max_length=200)
    contenido = HTMLField('Contenido')
    conocimiento = models.IntegerField(blank=True, null=True)
    tema = models.ForeignKey(Tema, on_delete=models.CASCADE)

    class Meta:
        ordering = ['capitulo']
        verbose_name = "Capitulo"
        verbose_name_plural = "Capitulos"

    def __str__(self):
        return '%s %s' % (self.capitulo, self.titulo)
Beispiel #16
0
class Article(models.Model):
    temps_de_lecture = models.CharField(max_length=255, null=True)
    titre = models.CharField(max_length=255)
    titre_slug = models.SlugField(max_length=255,
                                  editable=False,
                                  default=uuid.uuid4,
                                  null=True)
    description = models.TextField()
    categorie_id = models.ForeignKey(Categorie,
                                     on_delete=models.CASCADE,
                                     related_name="articles")
    contenu = HTMLField('article_description', null=True)
    photo = models.ImageField(upload_to='article')
    tag_name = models.ManyToManyField(Tag, related_name="tag_article")
    nom = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
    date_add = models.DateTimeField(auto_now_add=True)
    date_update = models.DateTimeField(auto_now=True)
    status = models.BooleanField(default=False)
    nb_com = models.PositiveIntegerField(default="0", editable=False)
    nb_like = models.PositiveIntegerField(default="0", editable=False)

    @property
    def nbr_like(self):
        n = self.likes.all().count()

        return n

    @property
    def nbr_comment(self):
        n = self.commentaires.all().count()

        return n

    def save(self, *args, **kwargs):
        u3 = uuid.uuid3(uuid.NAMESPACE_DNS, str(self.pk))

        self.titre_slug = '@' + slugify(self.titre + str(u3) + str(self.pk) +
                                        self.nom.username)
        self.nb_com = self.nbr_comment
        self.nb_like = self.nbr_like

        super(Article, self).save(*args, **kwargs)

    class Meta:
        verbose_name = 'Article'
        verbose_name_plural = 'Article'

    def __str__(self):
        return self.titre
Beispiel #17
0
class Post(models.Model):
    STATUS_CHOICES = (
        ('draft', 'Draft'),
        ('published', 'Published'),
    )

    author = models.ForeignKey(settings.AUTH_USER_MODEL,
                               on_delete=models.CASCADE)
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    slug = models.SlugField(max_length=150, unique=True, db_index=True)
    tags = models.ManyToManyField(Tag, blank=True)
    text = HTMLField('text')
    created_at = models.DateTimeField(auto_now_add=True)
    updated_on = models.DateTimeField(auto_now=True)
    published_at = models.DateTimeField(null=True, blank=True)
    status = models.CharField(max_length=10,
                              choices=STATUS_CHOICES,
                              default='draft')
    # The default Manager
    objects = models.Manager()

    # Custom Manager
    published = PublishedManager()
    drafts = DraftsManager()

    class Meta:
        ordering = ('-published_at', )
        index_together = (('id', 'slug'), )
        verbose_name = 'post'
        verbose_name_plural = 'posts'

    def save(self, *args, **kwargs):
        self.slug = slugify(self.title, allow_unicode=True)
        super(Post, self).save(*args, **kwargs)

    def publish(self):
        self.published_at = timezone.now()
        self.status = 'published'
        self.save()

    def __str__(self):
        return self.title

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

    def approved_comments(self):
        return self.comments.filter(approved_comment=True)
Beispiel #18
0
class Post(models.Model):
    title = models.CharField(max_length=100)
    content = HTMLField('Content', null=True) 
    date_posted = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(null=True)
    author = models.ForeignKey(User, on_delete=models.CASCADE, related_name='posts')

    def get_absolute_url(self):
        return reverse('posts:post-detail', kwargs={'pk': self.pk})

    def summary(self):
        return self.content[:50]

    def __str__(self):
        return self.title
Beispiel #19
0
class Blog(models.Model):
    title = models.CharField(max_length=200, unique=True)
    slug = models.SlugField(max_length=255, unique=True, primary_key=True)
    updated_on = models.DateTimeField(auto_now=True)
    content = HTMLField('content')
    created_on = models.DateTimeField(auto_now_add=True)
    status = models.IntegerField(choices=STATUS, default=0)
    thumbnail = models.ImageField(blank=False)
    author = models.ForeignKey(User, on_delete=models.CASCADE,null=True)
    category = models.CharField(choices=CATEGORY,max_length=50,default=PROGRAMMING,null=False)
    class Meta:
        ordering = ['-created_on']

    def __str__(self):
        return self.title
Beispiel #20
0
class Article(models.Model):
    titre = models.CharField(max_length=100)
    autheur = models.CharField(max_length=50)
    categorie = models.name = models.ForeignKey(
        'Categorie',
        related_name='article_categorie',
        on_delete=models.CASCADE)
    tag = models.name = models.ForeignKey('Tag',
                                          related_name='article_tag',
                                          on_delete=models.CASCADE)
    image = models.ImageField(upload_to='Article')
    content = HTMLField('Content')
    date_add = models.DateTimeField(auto_now_add=True)
    date_up = models.DateTimeField(auto_now=True)
    statut = models.BooleanField(default=False)
Beispiel #21
0
class Config(SingletonModel, SEOBase):
    name = models.CharField(max_length=255, default='Магазин', verbose_name='Название')
    logo = models.FileField(upload_to='site/logo', blank=True, null=True, verbose_name='Лого')
    phone = models.CharField(max_length=255, blank=True, null=True, verbose_name='Телефон')
    email = models.EmailField(blank=True, null=True, verbose_name='Email')
    address = models.TextField(blank=True, null=True, verbose_name='Адрес')
    title = models.CharField(max_length=255, default='Добро пожаловать', verbose_name='Заголовок')
    content = HTMLField(blank=True, null=True, verbose_name='Контент')
    gallery = models.OneToOneField('Gallery', blank=True, null=True, related_name='gallery', on_delete=models.CASCADE,
                                   verbose_name='Галлерея')
    page = models.OneToOneField('Page', blank=True, null=True, related_name='page', on_delete=models.CASCADE,
                                verbose_name='Страница')
    shop_page = models.OneToOneField('Page', blank=True, null=True, related_name='shop', on_delete=models.CASCADE,
                                verbose_name='Страница магазина')
    footer_1 = HTMLField(blank=True, null=True, verbose_name='Подвал Виджет_1')
    footer_2 = HTMLField(blank=True, null=True, verbose_name='Подвал Виджет_2')
    footer_3 = HTMLField(blank=True, null=True, verbose_name='Подвал Виджет_3')
    footer_4 = HTMLField(blank=True, null=True, verbose_name='Подвал Виджет_4')

    def __str__(self):
        return f"Настройки {self.name}"

    class Meta:
        verbose_name = "Настройки"
Beispiel #22
0
class Taffich(models.Model):
    titre = models.CharField(max_length=255, null=True, blank=True)
    description = HTMLField('shop/descripion')
    cover = models.ImageField(upload_to='blog')

    statut = models.BooleanField(default=True)
    date_add = models.DateTimeField(auto_now_add=True)
    date_update = models.DateTimeField(auto_now=True)

    class Meta:
        verbose_name = "Taffich"
        verbose_name_plural = "Taffichs"

    def __str__(self) -> str:
        return str(self.titre)
Beispiel #23
0
class NewsLetter(models.Model):
    EMAIL_STATUS_CHOICES = (('Draft', 'Draft'), ('Published', 'Published'))
    subject = models.CharField(max_length=250)
    body = HTMLField()
    #body = models.TextField()
    email = models.ManyToManyField(NewsletterUser)
    status = models.CharField(max_length=10, choices=EMAIL_STATUS_CHOICES)
    attachment = models.FileField(upload_to='newsletter/pdfs/',
                                  blank=False,
                                  null=False)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.subject
Beispiel #24
0
class Comment(models.Model):
    discussion = models.ForeignKey(Discussion)
    commenter = models.ForeignKey('auth.User', blank=True, null=True)
    body = HTMLField()
    created_date = models.DateTimeField(default=timezone.now)

    upvotes = models.IntegerField(default=0)
    downvotes = models.IntegerField(default=0)
    voters = models.ManyToManyField('auth.User', related_name='com_voters')

    def __str__(self):
        return '{0} - {1}'.format(self.commenter, self.discussion.get_title())

    def get_subcomments(self):
        return SubComment.objects.filter(comment=self)
Beispiel #25
0
class Posts(models.Model):
    title = models.CharField(max_length=200)
    #add WYSIWYG editor to body field in admin
    body = HTMLField('Content')
    image = models.FileField(null=True, blank=True)
    created_at = models.DateTimeField(default=timezone.now, blank=True)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name_plural = "Posts"
        ordering = [
            '-created_at',
        ]
Beispiel #26
0
class Post(models.Model):
    author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
    title = models.CharField(max_length=200)
    text = HTMLField('Text')
    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
Beispiel #27
0
class Outlines(models.Model):
    outline_img = models.FileField('Study Outline Image',
                                   upload_to='oultline_images')
    outline_title = models.CharField(max_length=100)
    outline_overview = models.CharField(max_length=200)
    outline_body = HTMLField('Note Body')
    outline_owner_name = models.CharField(max_length=200)
    outline_owner_title = models.CharField(max_length=200)

    class Meta:
        verbose_name = 'Bible Study Outline'
        verbose_name_plural = 'Bible Study Outlines'

    def __str__(self):
        return self.outline_title
Beispiel #28
0
class Testimonies(models.Model):
    testimony_img = models.FileField('Testimony Image',
                                     upload_to='testimony_images')
    testimony_title = models.CharField(max_length=100)
    testimony_overview = models.CharField(max_length=200)
    testimony_body = HTMLField('Testimony Body')
    testimony_owner_name = models.CharField(max_length=200)
    testimony_owner_title = models.CharField(max_length=200)

    class Meta:
        verbose_name = 'Testimony'
        verbose_name_plural = 'Testimonies'

    def __str__(self):
        return self.testimony_title
Beispiel #29
0
class Coordinator(models.Model):
    coord_portfolio = models.CharField(max_length=200)
    coord_img = models.FileField('File', upload_to='coordinators')
    coord_name = models.CharField(max_length=200)
    coord_course = models.CharField(max_length=200)
    coord_hostel = models.CharField(max_length=200)
    coord_contact = models.CharField(max_length=100)
    coord_role = HTMLField('Coordinator Role')

    class Meta:
        verbose_name = 'Coordinator'
        verbose_name_plural = 'Coordinators'

    def __str__(self):
        return self.coord_name + " - " + self.coord_portfolio
Beispiel #30
0
class Titre(models.Model):
    code = models.CharField(max_length=25)
    intitule = models.CharField(max_length=100)
    description = HTMLField(null=True)
    date_creation = models.DateTimeField(default=timezone.now)
    date_edition = models.DateTimeField(default=timezone.now)
    position = models.IntegerField(default=0)
    module = models.ForeignKey(Module, on_delete=models.CASCADE)

    class Meta:
        verbose_name = 'titre'
        ordering = ['position']

    def __str__(self):
        return self.intitule