Ejemplo n.º 1
0
        class FilerCssBackground(CssBackgroundAbstractBase):
            '''
            A CSS Background definition plugin, adapted for django-filer.
            '''
            image = FilerImageField(
                null=True,
                blank=True,
                help_text=CssBackgroundAbstractBase._blank_help)

            def get_image_url(self):
                return self.image.url if self.image_id else ''
Ejemplo n.º 2
0
class Newsletter(VersionedModel):
    date        = models.DateField()
    title       = models.CharField(max_length=100, help_text='Do not include date in title')
    content     = models.TextField()
    image       = FilerImageField(null=True, blank=True, on_delete=models.SET_NULL, related_name='newsletter_image')

    class Meta:
        ordering = ('-date',)

    def __str__(self):
        return self.title
Ejemplo n.º 3
0
class OnurKurulu(models.Model):
    ad = models.CharField(max_length=50)
    foto = FilerImageField(null=True, blank=True, related_name='kisi_foto')
    sira = models.IntegerField(verbose_name='sıra', blank=True, default=0)

    class Meta:
        verbose_name = 'Kişi'
        verbose_name_plural = "Onur Kurulu"

    def __str__(self):
        return self.ad
Ejemplo n.º 4
0
class Sponsorlar(models.Model):
    ad = models.CharField(max_length=50)
    foto = FilerImageField(null=True, blank=True, related_name='sponsor_foto')
    url = models.CharField(max_length=255, default='#')

    class Meta:
        verbose_name = "Sponsor"
        verbose_name_plural = "Sponsorlar"

    def __str__(self):
        return self.ad
Ejemplo n.º 5
0
class EmailHeaderCMSPlugin(VariableTemplateMixin, CMSPlugin):
    label = models.CharField(max_length=255)
    color = models.CharField(max_length=10, blank=True)

    image = FilerImageField(null=True, blank=True, default=None,
        on_delete=models.SET_NULL, verbose_name=_("image"))

    context_vars = ['label', 'image', 'color']

    def __str__(self):
        return self.label
Ejemplo n.º 6
0
class VideoPlayer(CMSPlugin):
    """
    Renders either an Iframe when ``link`` is provided or the HTML5 <video> tag
    """
    template = models.CharField(
        verbose_name=_('Template'),
        choices=get_templates(),
        default=get_templates()[0][0],
        max_length=255,
    )
    label = models.CharField(
        verbose_name=_('Label'),
        blank=True,
        max_length=255,
    )
    embed_link = models.CharField(
        verbose_name=_('Embed link'),
        blank=True,
        max_length=255,
        help_text=_(
            'Use this field to embed videos from external services '
            'such as YouTube, Vimeo or others. Leave it blank to upload video '
            'files by adding nested "Source" plugins.'),
    )
    poster = FilerImageField(
        verbose_name=_('Poster'),
        blank=True,
        null=True,
        on_delete=models.SET_NULL,
        related_name='+',
    )
    attributes = AttributesField(
        verbose_name=_('Attributes'),
        blank=True,
    )

    # Add an app namespace to related_name to avoid field name clashes
    # with any other plugins that have a field with the same name as the
    # lowercase of the class name of this model.
    # https://github.com/divio/django-cms/issues/5030
    cmsplugin_ptr = models.OneToOneField(
        CMSPlugin,
        related_name='%(app_label)s_%(class)s',
        parent_link=True,
        on_delete=models.CASCADE,
    )

    def __str__(self):
        return self.label or self.embed_link or str(self.pk)

    def copy_relations(self, oldinstance):
        # Because we have a ForeignKey, it's required to copy over
        # the reference from the instance to the new plugin.
        self.poster = oldinstance.poster
Ejemplo n.º 7
0
class SlickSliderImage(models.Model):
    """
    Image model für SlickSlider class.
    """
    class Meta:
        verbose_name = _('slider image')
        verbose_name_plural = _('slider images')

    slider = models.ForeignKey(
        SlickSlider,
        related_name="images",
        on_delete=models.CASCADE,
    )

    image = FilerImageField(
        verbose_name=_('slider Image'),
        related_name='slider_images_filer',
        on_delete=models.CASCADE,
    )

    link = models.URLField(
        verbose_name=_('image link'),
        null=True,
        blank=True,
    )

    link_target = models.BooleanField(
        verbose_name=_('image link target'),
        help_text=_('open link in new window'),
        default=True,
    )

    caption_text = models.TextField(
        _('caption text'),
        null=True,
        blank=True,
    )

    def __str__(self):
        """
        String representation of SlickSliderImage class.
        """
        return "{filename}".format(filename=self.image.original_filename)

    def full_width_dimensions(self):
        """
        Return the thumbnail dimensions based on Slider full width settings.
        """
        if self.slider.full_width:
            return "%sx%s" % (
                self.slider.image_max_width,
                self.slider.slider_max_height,
            )
        return "1200x500"
Ejemplo n.º 8
0
class Event(VersionedModel):
    name            = models.CharField(max_length=100)
    slug            = models.CharField(max_length=110, blank=True, null=True)
    start           = models.DateTimeField()
    finish          = models.DateTimeField(blank=True, null=True)
    location        = models.TextField(blank=True)
    latitude        = models.DecimalField(max_digits=9, decimal_places=6, blank=True, null=True)
    longitude       = models.DecimalField(max_digits=9, decimal_places=6, blank=True, null=True)
    description     = models.TextField(blank=True)
    category        = models.ForeignKey(Category, on_delete=models.SET_NULL, blank=True, null=True)
    hosting_group   = models.ForeignKey(Group, on_delete=models.SET_NULL, blank=True, null=True)
    image           = FilerImageField(null=True, blank=True, on_delete=models.SET_NULL, related_name='event_image')
    promote         = models.BooleanField(default=False)
    facebook_link   = models.URLField(blank=True, null=True, help_text='Link to Facebook event URL')
    eventbrite_link = models.URLField(blank=True, null=True, help_text='Link to Eventbrite event URL')
    other_link      = models.URLField(blank=True, null=True, help_text='Link to any other event page URL')
    online          = models.BooleanField(default=False)

    objects = EventManager()

    class Meta:
        ordering = ('-start',)

    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = self.generate_slug()
        super(Event, self).save()

    def generate_slug(self):
        datestr = self.start.strftime('%Y%m%d')
        slug = f'{slugify(self.name)}-{datestr}'

        if self.id:
            count = Event.objects.filter(slug=slug).exclude(id=self.id).count()
        else:
            count = Event.objects.filter(slug=slug).count()

        if count > 0:
            slug += f'-{count+1}'

        return slug

    @property
    def in_future(self):
        if self.start >= timezone.now() or (self.finish and self.finish >= timezone.now()):
            return True
        return False

    @property
    def in_past(self):
        return not self.in_future
Ejemplo n.º 9
0
class Image(Content):
    editable = True

    image = FilerImageField(verbose_name=_('image'), null=True,
                            related_name='+', on_delete=models.PROTECT)

    objects = SelectRelatedManager(select_related=['image'])

    class Meta:
        verbose_name = _('image')
        verbose_name_plural = _('images')
Ejemplo n.º 10
0
class Static(TranslatableModel):
    translations = TranslatedFields(
        name=models.CharField(max_length=60, verbose_name=_('Name')),
        slug=models.SlugField(max_length=60, verbose_name=_('Slug'), unique=True),
        body=RichTextUploadingField()
    )
    image = FilerImageField(null=True, blank=True)
    objects = TranslationManager()

    def __str__(self):
        return "{}".format(self.safe_translation_getter('name'))
Ejemplo n.º 11
0
class Active(models.Model):
    title = models.CharField('标题',max_length=300)
    body = models.TextField('内容')
    publish = models.DateTimeField('时间',default=timezone.now)
    image = FilerImageField(verbose_name = '图片',related_name='active_image', null=True)
    class Meta:
        ordering = ("-publish",)
        verbose_name = '活动'
        verbose_name_plural = '活动'
    def __str__(self):
        return self.title
Ejemplo n.º 12
0
class AbstractPageHead(CMSPlugin):
    image = FilerImageField(verbose_name=u'Image',
                            blank=True,
                            null=True,
                            on_delete=models.SET_NULL,
                            related_name='page_head_image')
    social_panel = models.BooleanField(u'Social panel', default=False)
    breadcrumbs = models.BooleanField(u'Breadcrumbs', default=False)

    class Meta:
        abstract = True
class Portfolio(CMSPlugin):
    image = FilerImageField()
    header = models.CharField(max_length=100)
    body = models.CharField(max_length=100)
    link = models.CharField(max_length=300)

    def __str__(self):
        return self.header

    def __unicode__(self):
        return self.header
Ejemplo n.º 14
0
class SuccessStory(CMSPlugin):
    storyId = models.CharField(max_length=10, default='Story ID')
    name = models.CharField(max_length=50, default='Candidate Name')
    excerpt = models.CharField(max_length=500, default='Excerpt')
    story_image_url = models.URLField(max_length=200,
                                      blank='True',
                                      default=_DEFAULT_IMAGE_URL)
    story_image = FilerImageField(null=True, blank=True)

    def __str__(self):
        return self.name
Ejemplo n.º 15
0
class Work(models.Model):
    #Work / Customer
    category = models.ForeignKey(Category)
    name = models.CharField(_('Name'), max_length=200)# (requis)
    description = models.TextField(_('Description'), null=True,blank=True)
    image = FilerImageField(null=True, blank=True, related_name="image_work")
    youtube_id = models.CharField(_('Youtube ID'), max_length=100)
    home_page = models.BooleanField()

    def __unicode__(self):
        return self.name
Ejemplo n.º 16
0
class FlatPageImage(models.Model):
    flatpage = models.ForeignKey(FlatPage, related_name='images')
    image = FilerImageField(null=True, blank=True)

    def __unicode__(self):
        if self.image:
            return "![%s][%s]" % (self.image.label, self.image.pk)

    class Meta:
        verbose_name = "Image"
        verbose_name_plural = "Image"
Ejemplo n.º 17
0
class Partner(models.Model):
    name = models.CharField(max_length=100, unique=True)
    position = models.PositiveIntegerField()
    is_active = models.BooleanField(default=True)
    image = FilerImageField(help_text='Please supply an image of this partner')

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = 'partners'
class ApplicationTile(CMSPlugin):
    app_thumbnail = FilerImageField(null=True,
                                    blank=True,
                                    related_name="app_thumbnail",
                                    on_delete=models.SET_NULL)
    app_name = models.CharField(max_length=50, default="Cell Types Database")
    app_description = models.CharField(
        max_length=140,
        default=
        "This section contains description copy for this Atlas or Database.")
    app_url = models.CharField(max_length=1000,
                               default="http://celltypes.brain-map.org/")
class HeroBanner(CMSPlugin):
    TopLeftImageCircle = FilerImageField(null=True,
                                         blank=True,
                                         related_name="top_left_image",
                                         on_delete=models.SET_NULL)
    TopRightImageCircle = FilerImageField(null=True,
                                          blank=True,
                                          related_name="top_right_image",
                                          on_delete=models.SET_NULL)
    BottomRightImageCircle = FilerImageField(null=True,
                                             blank=True,
                                             related_name="bottom_left_image",
                                             on_delete=models.SET_NULL)
    BottomLeftImageCircle = FilerImageField(null=True,
                                            blank=True,
                                            related_name="bottom_right_image",
                                            on_delete=models.SET_NULL)

    HeroText = models.CharField(
        max_length=140,
        default="Accelerating progress toward understanding the brain.")
Ejemplo n.º 20
0
class Location(models.Model):
    title = models.CharField(max_length=255)
    address = models.CharField(max_length=255)
    location = PlainLocationField(based_fields=['address'], zoom=7)
    logo = FilerImageField(null=True, blank=True, on_delete=models.CASCADE, related_name="locationlogo")
    class Meta:
        ordering = ('title',)
    class Meta:
        verbose_name = u'Lieu'
        verbose_name_plural = u'Lieux'
    def __str__(self):
        return self.title
Ejemplo n.º 21
0
class Edition(models.Model):
    header = FilerImageField(blank=True, null=True)
    header_caption = models.CharField(_('Header caption'), blank=True, null=True, max_length=255)
    header_description = models.TextField(_('Header description'), blank=True, null=True)
    published = models.BooleanField(_('Published'), default=False)
    publish_on = models.DateTimeField(_('Publish on'), default=datetime.now())
    before_vacation = models.BooleanField(
        _('Before vacation'), 
        help_text='If this newsletter is before a vacation, check \
                   for a lunch menu in the future')
    # This model also pulls in the current week's lunch menu
    # and any classifieds that are live in the classifieds app

    objects = models.Manager()
    published_objects = PublishedObjectManager()

    def __unicode__(self):
        return u'Newsletter %s: %s' % (self.pk, self.publish_on)

    def get_absolute_url(self):
        return reverse('newsletter-detail', args=(self.id,))

    class Meta:
        verbose_name = 'Edition'
        verbose_name_plural = 'Editions'
        ordering = ['-publish_on']
        get_latest_by = 'publish_on'

    def blog_posts(self):
        '''
        Returns a set of blog posts published within the last five days.
        '''
        five_days = self.publish_on - timedelta(days=7)
        return Entry.published.filter(creation_date__gte=five_days)

    @property
    def lunch_menu(self):
        ''' Returns the lunch menu for the newsletters date.
            If no such lunch menu exists, it returns none. '''
        if self.before_vacation:
            today = self.publish_on.date() + timedelta(weeks=2)
        else:
            today = self.publish_on.date() + timedelta(weeks=1)
        if today.weekday() < 5:  # If its Friday or earlier
            monday = today - timedelta(days=today.weekday())
        else:
            monday = today + timedelta(days=-today.weekday(), weeks=1)
        try:
            menu = LunchMenu.objects.get(start_date=monday)
        except:
            menu = None

        return menu
Ejemplo n.º 22
0
class NewsItemTranslation(TranslationModel):
    news_item = models.ForeignKey('NewsItem')
    title = ShortTextField(blank=True)
    body = models.TextField(blank=True)
    image = FilerImageField(null=True)

    class Meta:
        """Model metadata options"""
        unique_together = (('news_item', 'language'))

    def __unicode__(self):
        return self.title
Ejemplo n.º 23
0
class Agency(models.Model):
    agency = models.CharField(
        max_length=500,
        null=True,
        blank=True,
        verbose_name='Орган рассмотрения выдачи льготы/субсидии')
    building = models.CharField(max_length=500,
                                null=True,
                                blank=True,
                                verbose_name='Учреждение')
    activity = RichTextUploadingField(null=True,
                                      blank=True,
                                      verbose_name='Деятельность')
    image = FilerImageField(null=True,
                            blank=True,
                            verbose_name='Изображение',
                            on_delete=models.CASCADE,
                            related_name='agency_image')
    address = models.CharField(max_length=50,
                               null=True,
                               blank=True,
                               verbose_name='Адрес')
    department = models.CharField(max_length=50,
                                  null=True,
                                  blank=True,
                                  verbose_name='Департамент')
    work_time = models.CharField(max_length=50,
                                 null=True,
                                 blank=True,
                                 verbose_name='Режим работы')
    contact_person = models.CharField(max_length=50,
                                      null=True,
                                      blank=True,
                                      verbose_name='Контактное лицо')
    contact_phone = models.CharField(max_length=50,
                                     null=True,
                                     blank=True,
                                     verbose_name='Контакты тел.')
    geo_lat = models.CharField(max_length=50,
                               null=True,
                               blank=True,
                               verbose_name='широта')
    geo_long = models.CharField(max_length=50,
                                null=True,
                                blank=True,
                                verbose_name='долгота')

    def __str__(self):
        return '{}'.format(self.agency)

    class Meta:
        verbose_name = 'Орган рассмотрения выдачи льготы/субсидии'
        verbose_name_plural = 'Орган рассмотрения выдачи льготы/субсидии'
Ejemplo n.º 24
0
    class FilerImageContent(ContentWithFilerFile):
        """
        Create a media file content as follows::

            from feincms.contents import FilerImageContent
            Page.create_content_type(FilerImageContent, TYPE_CHOICES=(
                ('inline', _('Default')),
                ('lightbox', _('Lightbox')),
                ('whatever', _('Whatever')),
            ))

        For a media file of type 'image' and type 'lightbox', the following
        templates are tried in order:

        * content/mediafile/image_lightbox.html
        * content/mediafile/lightbox.html
        * content/mediafile/image.html
        * content/mediafile/default.html

        The context contains ``content`` and ``request`` (if available).

        The content.mediafile attribute are as follows (selection):
        label, description, default_caption, default_alt_text,
        author, must_always_publish_author_credit,
        must_always_publish_copyright, date_taken, file, id, is_public, url
        """

        mediafile = FilerImageField(verbose_name=_("image"), related_name="+")
        caption = models.CharField(_("caption"), max_length=1000, blank=True)
        url = models.CharField(_("URL"), max_length=1000, blank=True)

        file_type = "image"

        class Meta:
            abstract = True
            verbose_name = _("image")
            verbose_name_plural = _("images")

        @classmethod
        def initialize_type(cls, TYPE_CHOICES=None):
            if TYPE_CHOICES is None:
                raise ImproperlyConfigured("You have to set TYPE_CHOICES when"
                                           " creating a %s" % cls.__name__)

            cls.add_to_class(
                "type",
                models.CharField(
                    _("type"),
                    max_length=20,
                    choices=TYPE_CHOICES,
                    default=TYPE_CHOICES[0][0],
                ),
            )
Ejemplo n.º 25
0
class User(AbstractUser):

    username = models.CharField(
        _('username'),
        max_length=150,
        unique=True,
        help_text=
        _('Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.'
          ),
        validators=[AbstractUser.username_validator],
        error_messages={
            'unique': _("User with that username already exists."),
        },
    )
    phone = models.CharField(max_length=12,
                             unique=True,
                             verbose_name=_('Phone number or Username'))
    first_name = models.CharField(max_length=30,
                                  blank=True,
                                  verbose_name=_('First name'))
    last_name = models.CharField(max_length=30,
                                 blank=True,
                                 verbose_name=_('Last name'))
    date_joined = models.DateTimeField(
        auto_now_add=True,
        verbose_name=_('Date joined'),
    )
    is_active = models.BooleanField(
        default=True,
        verbose_name=_('Active'),
    )
    image = FilerImageField(
        null=True,
        blank=True,
        verbose_name=_('Avatar'),
    )

    EMAIL_FIELD = 'email'
    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = [
        'email',
    ]
    objects = UserManager()

    class Meta:
        verbose_name = _('User')
        verbose_name_plural = _('Users')

    def __str__(self):
        return self.first_name if self.first_name else self.phone

    def is_customer(self):
        return True if Customer.objects.filter(user=self) else False
Ejemplo n.º 26
0
class SlidePlugin(CMSPlugin):
    LINK_TARGETS = (
        ('', _('same window')),
        ('_blank', _('new window')),
        ('_parent', _('parent window')),
        ('_top', _('topmost frame')),
    )

    image = FilerImageField(verbose_name=_('image'), blank=True, null=True)
    content = HTMLField("Content", blank=True, null=True)
    url = models.URLField(_("Link"), blank=True, null=True)
    page_link = PageField(
        verbose_name=_('Page'),
        blank=True,
        null=True,
        help_text=_("A link to a page has priority over a text link.")
    )
    target = models.CharField(
        verbose_name=_("target"),
        max_length=100,
        blank=True,
        choices=LINK_TARGETS,
    )
    link_text = models.CharField(
        verbose_name=_('link text'),
        max_length=200,
        blank=True
    )


    def __unicode__(self):
        image_text = content_text = ''

        if self.image_id:
            image_text = u'%s' % (self.image.name or self.image.original_filename)
        if self.content:
            text = strip_tags(self.content).strip()
            if len(text) > 100:
                content_text = u'%s...' % text[:100]
            else:
                content_text = u'%s' % text

        if image_text and content_text:
            return u'%s (%s)' % (image_text, content_text)
        else:
            return image_text or content_text

    def get_link(self):
        if self.page_link_id:
            return self.page_link.get_absolute_url()
        if self.url:
            return self.url
        return False
Ejemplo n.º 27
0
class ModelPageTitle(CMSPlugin):
    pic = FilerImageField(verbose_name='Изображение для шапки',
                          blank=True,
                          null=True,
                          on_delete=models.SET_NULL)
    conf = models.ForeignKey(PageTitleConf,
                             on_delete=models.PROTECT,
                             blank=True,
                             null=True)

    def copy_relations(self, oldinstance):
        self.conf = oldinstance.conf
Ejemplo n.º 28
0
class BaseEntityComment(
        with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
    """
    Comment model
    """
    entity = deferred.ForeignKey('BaseEntity', verbose_name=_('Entity'))

    origin_name = models.CharField(
        verbose_name=_('Origin name'),
        help_text=_(
            'Comment owner name. You must indicate the source of comment (company name/full name '
            'and position of the company representative)'),
        blank=False,
        null=False,
        max_length=255)
    text = models.TextField(
        verbose_name=_('Text'),
        help_text=
        _('Text of comment, contains a quote with a rebuttal (maximum 300 symbols).'
          ),
        blank=False,
        null=False,
        max_length=300)
    origin_url = models.CharField(
        verbose_name=_('Origin url'),
        help_text=
        _('Comment owner link, refers to materials containing a denial on the media website.'
          ),
        blank=True,
        null=True,
        max_length=255)
    logo = FilerImageField(
        verbose_name=_('Origin logo'),
        help_text=_('Comment owner logo'),
        blank=True,
        null=True,
    )
    bind_to = models.TextField(
        verbose_name=_('Bind to'),
        help_text=
        _('Refers to a news item that has been commented on. If the news has been published by several '
          'media outlets, you can post links to each source. Including yourself. Separate by newline'
          ),
        blank=True,
        null=True)

    class Meta:
        abstract = True
        verbose_name = _("Publication comment")
        verbose_name_plural = _("Publication comments")

    def __str__(self):
        return "{} ({})".format(self.origin_name, self.origin_url)
Ejemplo n.º 29
0
class Product(models.Model):
    category = models.ForeignKey(Category, on_delete=models.CASCADE)
    sku = models.CharField(max_length=20)
    name = models.CharField(max_length=200)
    description = models.TextField()
    image = FilerImageField(related_name='product_image')
    website = models.URLField(null=True)
    stock = models.PositiveIntegerField(default=0)
    price = models.DecimalField(max_digits=10, decimal_places=2, default=0)

    def __str__(self):
        return self.name
Ejemplo n.º 30
0
class Website(models.Model):
    owner = models.ForeignKey(User, on_delete=models.CASCADE)
    name = models.CharField(max_length=255)
    url = models.URLField()
    thumbnail = FilerImageField(max_length=5000, on_delete=models.CASCADE)

    def __unicode__(self):
        return "%s:%s" % (self.owner, self.name)

    class Meta:
        verbose_name = "Website"
        verbose_name_plural = "Websites"