Exemple #1
0
class Project(models.Model):
    name = models.CharField(verbose_name=_("Name"),
                            help_text=_("Required & Unique"),
                            max_length=255,
                            unique=True)
    slug = models.SlugField(verbose_name=_("URL safe name"),
                            max_length=255,
                            unique=True)
    description = EditorJsField(verbose_name=_("description"),
                                help_text=_("Not Required"),
                                blank=True)
    type = models.ForeignKey(ProjectType,
                             on_delete=models.RESTRICT,
                             related_name="project_type")
    skills = models.ManyToManyField(
        Skill,
        verbose_name=_("Used Skills"),
        help_text=_("Add the skills used on this project"),
        related_name="skills")
    is_active = models.BooleanField(verbose_name=_("Project Visibility"),
                                    help_text=_("Change project visibility"),
                                    default=True)
    created_at = models.DateTimeField(_("Created at"),
                                      auto_now_add=True,
                                      editable=False)
    updated_at = models.DateTimeField(_("Updated at"), auto_now_add=True)

    class Meta:
        ordering = ("-created_at", )
        verbose_name = _("Project")
        verbose_name_plural = _("Projects")

    def __str__(self):
        return self.name
class Post(models.Model):
    title = models.CharField(max_length=60)
    body = EditorJsField(
        editorjs_config={
            "tools": {
                "Link": {
                    "config": {
                        "endpoint": '/linkfetching/'
                    }
                },
                "Image": {
                    "config": {
                        "endpoints": {
                            "byFile": '/uploadi/',
                            "byUrl": '/uploadi/'
                        },
                    }
                },
                "Attaches": {
                    "config": {
                        "endpoint": '/uploadf/'
                    }
                }
            }
        })
class Article(models.Model):
    title = models.CharField(max_length=220)
    # slug = AutoSlugField(populate_from='title', unique_with=['pub_date'])
    slug = models.CharField(max_length=220)
    body = EditorJsField()
    excerpt = models.CharField(max_length=180, null=True, blank=True)
    tags = models.ManyToManyField(Tag)
    pub_date = models.DateField(auto_now_add=True)
    published = models.BooleanField(default=False)
    thumbnail = models.ImageField(
        upload_to='uploads/', null=True, blank=True)
Exemple #4
0
class Post(models.Model):
    title = models.TextField()
    body = EditorJsField(
        editorjs_config={
            "tools": {
                "Table": {
                    "disabled": False,
                    "inlineToolbar": True,
                    "config": {
                        "rows": 2,
                        "cols": 3,
                    },
                }
            }
        })
Exemple #5
0
class Post(share_models.PostTypeModel):
    category = models.ForeignKey(Category,
                                 null=True,
                                 default=None,
                                 blank=True,
                                 on_delete=models.SET_NULL)
    pop_in_banner = models.BooleanField(default=False)
    slug = models.SlugField(unique=True)
    read_time = models.IntegerField(help_text="Time to read (Unit:minutes)")
    tags = TaggableManager(blank=True)
    view_count = models.IntegerField(default=0)
    photo = models.ForeignKey(Gallery,
                              default=None,
                              blank=True,
                              null=True,
                              on_delete=models.SET_NULL)
    body = EditorJsField(
        editorjs_config={
            'holder': 'holder',
            "tools": {
                "Table": {
                    "disabled": False,
                    "inlineToolbar": True,
                    "config": {
                        "rows": 2,
                        "cols": 3,
                    },
                }
            }
        })

    def tag_names(self):
        return self.tags.names()

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

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse_lazy('article-detail', args=[self.slug])

    class Meta:
        ordering = ["-pub_date", "-timestamp"]
class Blog(models.Model):
    title = models.CharField(max_length = 10000)
    body = EditorJsField(editorjs_config ={ "tools": {
            "Image": {
                "config": {
                    "endpoints": {
                        "byFile": 'http://localhost:8000/fileUpload', 
                        "byUrl": 'http://localhost:8000/fetchUrl',
                    },
                    "additionalRequestHeaders":[{"Content-Type":'multipart/form-data'}]
                }
            },
            "header": {
                "class": "Header",
                "shortcut": "CMD+SHIFT+H",
            },
        }},null=True, blank=True)

    image = models.ImageField(upload_to ='blog_image/', null=True, blank=True) 
    lastUpdated = models.DateTimeField('date created', default=timezone.now)
    user = models.ForeignKey(User, null=True, blank=True, on_delete=models.SET_NULL)
    audio_complete = models.IntegerField(default=0)
    reading_time = models.IntegerField(default=0)
    slug = models.SlugField(max_length=250,null=True,blank=True,unique=True)
    is_private = models.BooleanField(default=False)
    created_at = models.DateTimeField(editable=False)
    updated_at = models.DateTimeField(editable=False)
    link_opened = models.IntegerField(default=0)
    tags = models.ManyToManyField(Tag,blank=True)
    clap_count = models.IntegerField(default=0)
    is_new = models.BooleanField(default=True)
    view_count = models.IntegerField(default=0)
    must_read = models.BooleanField(default=False)

    def get_absolute_url(self):
        return "/"+ self.user.slug +"/"+self.slug

    def __str__(self):
        return str(self.title)
Exemple #7
0
class Project(models.Model):

    author = models.ForeignKey(settings.AUTH_USER_MODEL,
                               on_delete=models.CASCADE,
                               verbose_name='Автор')

    manager = models.ForeignKey(User,
                                null=True,
                                on_delete=models.PROTECT,
                                related_name='project_manager',
                                verbose_name='Менеджер проекта')

    customer = models.ForeignKey(User,
                                 null=True,
                                 on_delete=models.PROTECT,
                                 related_name='project_customer',
                                 verbose_name='Заказчик')

    performer = models.ForeignKey(User,
                                  null=True,
                                  on_delete=models.PROTECT,
                                  related_name='project_performer',
                                  verbose_name='Исполнттель')

    type_project = models.ForeignKey('TypeProject',
                                     null=True,
                                     on_delete=models.PROTECT,
                                     verbose_name='Тип проекта')

    categories_project = models.ManyToManyField('CategoryProject',
                                                verbose_name="Категории")

    status_project = models.ForeignKey('StatusProject',
                                       null=True,
                                       on_delete=models.PROTECT,
                                       verbose_name='Статус')

    title = models.CharField(max_length=255,
                             db_index=True,
                             verbose_name='Название')

    description = models.TextField(blank=True, verbose_name="Описание")

    technical_task = EditorJsField(blank=True,
                                   verbose_name="Техническое задание")

    contract = models.URLField(max_length=255,
                               db_index=True,
                               verbose_name='Ссылка на договор')

    total_budget = MoneyField(max_digits=14,
                              decimal_places=2,
                              default_currency='RUB',
                              default=0,
                              verbose_name='Бюджет проекта')

    spent_budget = MoneyField(max_digits=14,
                              decimal_places=2,
                              default_currency='RUB',
                              default=0,
                              verbose_name='Расход')

    balance_budget = MoneyField(max_digits=14,
                                decimal_places=2,
                                default_currency='RUB',
                                default=0,
                                verbose_name='Остаток')

    cteated_date = models.DateTimeField(default=timezone.now,
                                        verbose_name='Создан')

    update_date = models.DateTimeField(auto_now_add=True,
                                       verbose_name='Обновлён')

    published_date = models.DateTimeField(blank=True,
                                          null=True,
                                          verbose_name='Публикация')

    start_date = models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name='Дата старта')

    completed_date = models.DateTimeField(
        blank=True,
        verbose_name='Дата завершения',
    )

    priority = models.PositiveSmallIntegerField(
        default=False,
        verbose_name='Приоритет',
    )

    is_active = models.BooleanField(default=True, verbose_name='Активный')

    is_done = models.BooleanField(default=False, verbose_name='Реализован')

    class Meta:
        verbose_name = 'Проект'
        verbose_name_plural = 'Проекты'
        ordering = ['cteated_date']

    def __str__(self):
        return self.title
Exemple #8
0
class Post(models.Model):
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(max_length=250, blank=True)
    body = EditorJsField(editorjs_config={
        "tools": {
            "config": {
                "placeholder": 'Write your post content here...'
            },
            "Image": {
                "config": {
                    "endpoints": {
                        "byFile": '/imageUPload/',
                        "byUrl": '/imageUPload/'
                    },
                    "additionalRequestHeaders": [{
                        "Content-Type":
                        'multipart/form-data'
                    }]
                }
            },
            "Attaches": {
                "config": {
                    "endpoint": '/fileUPload/',
                },
            },
        }
    },
                         blank=True)
    slug = models.SlugField()
    created = models.DateTimeField(editable=False)
    modified = models.DateTimeField()
    header = models.ImageField(upload_to='uploads', blank=True)
    snippet = models.CharField(max_length=250, blank=True)
    likes = models.ManyToManyField(User, related_name='post_likes', blank=True)
    draft = models.BooleanField(default=False)
    tags = TaggableManager(blank=True)

    # objects = PersonManager()

    def natural_key(self):
        return self.title

    def save(self, *args, **kwargs):
        if not self.id:
            self.created = timezone.now()
            self.slug = slugify(self.title)
        self.modified = timezone.now()

        # img = Image.open(self.header.path)
        # if img.height > 300 or img.width > 300:
        #     output_size = (300, 300)
        #     img.thumbnail(output_size)
        #     img.save(self.image.path)

        return super(Post, self).save(*args, **kwargs)

    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('post-detail', args=[self.slug])

    class Meta:
        ordering = ['-created']
        unique_together = ['title']