Exemple #1
0
class library_images(models.Model):
    image = models.ImageField()
    library = models.ForeignKey('core.library', on_delete=models.CASCADE)

    def __str__(self):
        return self.library.name

    class Meta:
        verbose_name_plural = 'Library Images'
Exemple #2
0
class Images(models.Model):
    id = models.AutoField(primary_key=True)
    ngo = models.ForeignKey(NgoDetail,
                            on_delete=models.CASCADE,
                            related_name='images')
    image = models.ImageField(upload_to=user_directory_path_images)

    class Meta:
        verbose_name_plural = "Images"
Exemple #3
0
class File(BaseModel):
    """
    """
    name = models.CharField(max_length=300,
                            blank=True,
                            null=True,
                            default=fake.text)
    doc = models.FileField(blank=True, null=True)
    image = models.ImageField(blank=True, null=True)
Exemple #4
0
class UserDetail(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    seller = models.OneToOneField("Seller", blank=True, null=True)
    buyer = models.OneToOneField("Buyer", blank=True, null=True)
    icon = models.ImageField(upload_to='icons', blank=True, null=True)
    bio = models.CharField(max_length=420, default='', blank=True, null=True)
    joined = models.DateTimeField()
    activation_key = models.CharField(max_length=100)
    recovery_key = models.CharField(max_length=100, blank=True)
Exemple #5
0
class ServiceAccount(models.Model):
    """
    ServiceAccount: Cuenta para prestadores de servicio
    **Atributos db:**
    """
    identity_card = models.PositiveIntegerField(
        verbose_name=_('identity card'),
        validators=[MaxValueValidator(999999999)])
    driver_license = models.ImageField(verbose_name=_('driver\'s license'),
                                       upload_to='license',
                                       blank=True)
    phone = models.CharField(verbose_name=_('phone'),
                             max_length=11,
                             validators=[phone_validator])
    photo = models.ImageField(verbose_name=_('photo'),
                              upload_to='servicePhoto',
                              blank=True)
    birthdate = models.DateField(verbose_name=_('birthdate'))
    address = models.CharField(verbose_name=_('address'), max_length=100)
    vehicle = models.OneToOneField('sw_vehicles.Vehicle',
                                   verbose_name=_('vehicle'))
    identity_check = models.BooleanField(verbose_name=_('identity verified'),
                                         default=False)
    bankaccount = models.OneToOneField('sw_payments.BankAccount',
                                       verbose_name=_('bank account'),
                                       null=True)
    balance = models.DecimalField(verbose_name=_('balance'),
                                  max_digits=6,
                                  decimal_places=4,
                                  default=0)
    last_location_point = models.PointField(
        verbose_name=_('last location point'), null=True, blank=True)
    last_location_date = models.DateTimeField(
        verbose_name=_('last location date'), blank=True, null=True)
    created_at = models.DateTimeField(verbose_name=_('created at'),
                                      auto_now_add=True,
                                      editable=False)
    updated_at = models.DateTimeField(verbose_name=_('updated at'),
                                      auto_now=True,
                                      editable=False)

    class Meta:
        verbose_name = _('service provider')
        verbose_name_plural = _('services provider')
Exemple #6
0
class Linea(models.Model):
    nombre = models.CharField(max_length=100)
    slug = models.SlugField(max_length=120, blank=True, null=False)
    descripcion = models.TextField(blank=True, null=True)
    foto = models.CharField(max_length=20, blank=True, null=True)
    img_panorama = models.ImageField(max_length=200,
                                     upload_to='linea',
                                     blank=True,
                                     null=True)
    img_cuadrada = models.ImageField(max_length=200,
                                     upload_to='linea',
                                     blank=True,
                                     null=True)
    color_polilinea = models.CharField(max_length=20, blank=True, null=True)
    info_empresa = models.TextField(blank=True, null=True)
    info_terminal = models.TextField(blank=True, null=True)
    localidad = models.CharField(max_length=50, blank=True, null=True)
    cp = models.CharField(max_length=20, blank=True, null=True)
    telefono = models.CharField(max_length=200, blank=True, null=True)
    envolvente = models.PolygonField(blank=True, null=True)

    def __str__(self):
        return self.nombre

    def save(self, *args, **kwargs):
        self.slug = slugify(self.nombre)
        super(Linea, self).save(*args, **kwargs)

    def get_absolute_url(self, ciudad_slug=None):
        # chequear si la linea está en esta ciudad, sino tirar excepcion
        if ciudad_slug is None:
            try:
                ciudad_slug = self.ciudades.all().only('slug')[0].slug
            except Exception as e:
                print(e)
                print(self)
                return ""
        else:
            get_object_or_404(Ciudad, slug=ciudad_slug, lineas=self)
        return reverse('ver_linea',
                       kwargs={
                           'nombre_ciudad': ciudad_slug,
                           'nombre_linea': self.slug
                       })
Exemple #7
0
class User(AbstractBaseUser, PermissionsMixin):
    username = models.CharField(max_length=200, unique=True, null=True)
    email = models.EmailField('email address',
                              unique=True,
                              blank=True,
                              null=True)
    avatar = models.ImageField(upload_to='avatars/',
                               null=True,
                               blank=True,
                               max_length=500)
    position = models.PointField(srid=4326, blank=True, null=True)
    locale = models.CharField(max_length=100,
                              choices=LOCALE_CHOICES,
                              default=LOCALE_CHOICES[0][0])
    number = models.CharField(max_length=100, unique=True, null=True)

    btc_wallet = models.CharField(max_length=200, null=True)
    btc_wallet_direct = models.CharField(max_length=200, null=True)

    is_active = models.BooleanField('active', default=True)
    is_staff = models.BooleanField('manager', default=False)

    objects = UserManager()

    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = []

    class Meta:
        verbose_name = 'user'
        verbose_name_plural = 'users'

    def __str__(self):
        return self.username

    def get_full_name(self):
        return '{}: {}'.format(self.name, self.email)

    def get_short_name(self):
        return self.username

    def email_user(self, subject, message, from_email=None, **kwargs):
        send_mail(subject, message, from_email, [self.email], **kwargs)

    @property
    def has_avatar(self):
        return True if self.avatar and hasattr(self.avatar, 'url') else False

    @property
    def avatar_url(self):
        return self.avatar.url if self.has_avatar else static('ic-profile.svg')

    @property
    def bc_username(self):
        ubc = UserBlockChain.on_bc.filter(user=self).first()

        return ubc.username if ubc is not None else self.username
Exemple #8
0
class User(AbstractUser):
    GENDER_CHOICES = (
        ("F", _("Female")),
        ("M", _("Male")),
    )
    STATE_CHOICES = (
        ("Normal", _("Normal")),
        ("Confirmed Case", _("Confirmed Case")),
        ("Suspicious Case", _("Suspicious Case")),
        ("Recovered", _("Recovered")),
        ("Dead", _("Dead")),
    )
    photo = models.ImageField(_('photo'),
                              upload_to='accounts/users',
                              null=True,
                              blank=True)
    notification = models.TextField(blank=True, null=True)
    address = models.CharField(_('address'), max_length=200, null=True)
    phone = models.CharField(_('phone'), max_length=500, blank=True)
    gender = models.CharField(_('gender'),
                              choices=GENDER_CHOICES,
                              max_length=50,
                              blank=True,
                              null=True,
                              default="M")
    state = models.CharField(_('state'),
                             max_length=50,
                             choices=STATE_CHOICES,
                             default="active")
    location = models.PointField(null=True, blank=True)
    props = JSONField(blank=True, default=dict)
    slug = models.SlugField(max_length=1000, unique=True)
    created = models.DateTimeField(default=now, editable=False)

    def __str__(self):
        return self.username

    def random_string_generator(self, size=10, chars=string.digits):
        return ''.join(random.choice(chars) for _ in range(size))

    def unique_slug_generator(self):
        new_slug = self.random_string_generator(size=7)
        qs_exists = User.objects.filter(slug=new_slug).exists()
        if qs_exists:
            return self.unique_slug_generator()
        return new_slug

    def save(self, *args, **kwargs):
        if self.slug == "":
            self.slug = self.unique_slug_generator()
        super(User, self).save()

    def get_image(self):
        if self.photo:
            return self.photo.url
        return ""
Exemple #9
0
class TrabajadorCapacitacion(models.Model):
    trabajador = models.ForeignKey(Trabajador, blank=True, null=True, on_delete=models.CASCADE,)
    capacitacion = models.ForeignKey(Capacitacion, blank=True, null=True, on_delete=models.CASCADE)
    fecha_inicio = models.DateField()
    fecha_fin = models.DateField()
    observacion = models.CharField(max_length=4096, blank=True, null=True)
    certificado = models.ImageField(upload_to='capacitacion/', blank=True, null=True)

    def __unicode__(self):
        return u"%s %s %s %s" % (self.trabajador, self.capacitacion, self.fecha_inicio, self.fecha_fin)
class Image(AbstractAttachment):
	"""An image associated with a map feature"""
	file = models.ImageField(upload_to=feature_directory_path, null=True, blank=False, verbose_name='Image')
	description = RichTextField(null=True, blank=True)
	copyright = models.CharField(blank=True, max_length=140)
	
	def save(self, *args, **kwargs):
		"""Bleach the description, Update the 'count' attribute of the feature"""
		self.description = bleach.clean(self.description, tags=['strong', 'em', 'a'], attributes={'a': ['href']})
		super(Image, self).save(*args, **kwargs)
Exemple #11
0
class Photo(Context):
    image01 = models.ImageField('Image',upload_to='/media/',null=True,blank=True)
    def thumb01(self):
        return u'<a href="%s"><img src="%s" style="width:300px" /></a>' % (os.path.join('/static/' + self.image01.url),os.path.join('/static/' + self.image01.url))
    thumb01.short_description = 'Image'
    thumb01.allow_tags = True
    thumb01.mark_safe = True
    class Meta:
        managed = True
        db_table = 'photos'
Exemple #12
0
class Project(models.Model):
    name = models.CharField('Название проекта', max_length=32)
    description = models.TextField('Описание проекта')
    longitude = models.FloatField('Широта', null=True, blank=True)
    latitude = models.FloatField('Долгота', null=True, blank=True)
    text_location = models.TextField('Описание местоположения')
    picture = models.ImageField(upload_to='photos', max_length=1024)

    def __str__(self):
        return self.name
Exemple #13
0
class Photo(models.Model):
    url = models.ImageField()
    tree = models.ForeignKey(Tree, on_delete=models.CASCADE)
    user = models.ForeignKey(AUTH_USER_MODEL, on_delete=models.CASCADE)

    class Meta:
        db_table = "photos"

    def __str__(self):
        return str(self.url)
class ExperienceImage(models.Model):
    experience = models.ForeignKey(Experience, related_name='images')
    image = models.ImageField(upload_to='experiences/')
    default = models.BooleanField(default=False)

    def __unicode__(self):
        return '{} Image'.format(self.experience.title)

    def __str__(self):
        return self.__unicode__()
Exemple #15
0
class Product(models.Model):
    image = models.ImageField()
    name = models.CharField(max_length=255)
    description = models.CharField(max_length = 500)
    price = models.IntegerField()    
    stockAvailable = models.BooleanField()
    retailer = models.ForeignKey(Retailer,on_delete=models.CASCADE)
    
    def __str__(self):
        return self.name
Exemple #16
0
class Employee(models.Model):
    """ 
        ForignKey==>
        This means that a given user can be the author of many different blog posts
        but not the other way around.
    """
    user = models.OneToOneField(get_user_model(), on_delete=models.CASCADE)
    # phoneNumber = == >
    gender = models.CharField(choices=GENDER_CHOICES,
                              max_length=20,
                              blank=True,
                              null=True)

    birth_date = models.DateField(blank=True, null=True)
    education = models.CharField(
        max_length=25,
        blank=True,
        choices=EDUCATION_CHOICES,
    )
    thumb = models.ImageField(default='default-thumb.jpeg',
                              upload_to='employee/thumb',
                              blank=True)
    is_active = models.BooleanField(default=True)
    last_modified = models.DateTimeField(auto_now_add=False, auto_now=True)
    created = models.DateTimeField(auto_now_add=True, auto_now=False)
    image = models.ImageField(default='default.jpg',
                              blank=True,
                              upload_to='employee')

    location = models.PointField(srid=4326, blank=True, null=True)

    def __str__(self):
        return self.user.email

    def save(self, *args, **kwargs):
        from main_app.utils import generate_thumbnail
        self.thumb = generate_thumbnail(self.image)
        super(Employee, self).save(*args, **kwargs)

    def delete(self, *args, **kwargs):
        from main_app.utils import delete_from_s3
        delete_from_s3([self.image, self.thumb])
        super(Employee, self).delete(*args, **kwargs)
Exemple #17
0
class POI(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(verbose_name='POI Name', max_length=100)
    type = models.CharField(verbose_name='POI Type', max_length=100)
    address = models.CharField(verbose_name='POI Address', max_length=200)
    location = models.PointField(srid=4326, verbose_name='位置', null=True)
    picture = models.ImageField(verbose_name='POI Picture', upload_to='poi/')

    def __str__(self):
        return self.name
Exemple #18
0
class land_image(models.Model):
    land_image_id = models.AutoField(primary_key=True)
    land_id = models.ForeignKey(land, on_delete=models.SET_NULL, null=True)
    image = models.ImageField(upload_to='uploads/% Y/% m/% d/',
                              blank=True,
                              null=True)
    pub_date = models.DateTimeField(auto_now_add=True, null=True)

    def __int__(self):
        return self.on_sale_id
Exemple #19
0
class Embeded(Media):
    content = models.TextField()
    thumbnail = models.ImageField(upload_to=THUMBNAIL_UPLOAD_DIR,
                                  null=True,
                                  blank=True)

    class Meta:
        app_label = 'mediastore'
        verbose_name = _('embeded media')
        verbose_name_plural = _('embeded media')
Exemple #20
0
class TravelPlan(models.Model):
    name = models.CharField(max_length=254)
    description = models.TextField(blank=True)
    stations = models.ManyToManyField('Station', through='TravelPlanStations')
    image = models.ImageField(null=True,
                              blank=True,
                              upload_to="images/travel_plan/")

    def __str__(self):
        return self.name
Exemple #21
0
class Shipment(models.Model):
    client = models.ForeignKey('sw_users.ClientAccount',
                               verbose_name=_('client'))
    service = models.ForeignKey('sw_users.ServiceAccount',
                                verbose_name=_('service provider'),
                                null=True)
    shipmenttype = models.ForeignKey('ShipmentType',
                                     verbose_name=_('shipment type'))
    packagetype = models.ForeignKey('sw_vehicles.PackageType',
                                    verbose_name=_('package type'))
    photo1 = models.ImageField(verbose_name=_('photo 1'),
                               upload_to='shipmentPhoto',
                               blank=True)
    photo2 = models.ImageField(verbose_name=_('photo 2'),
                               upload_to='shipmentPhoto',
                               blank=True)
    photo3 = models.ImageField(verbose_name=_('photo 3'),
                               upload_to='shipmentPhoto',
                               blank=True)
    tags = models.CharField(verbose_name=_('tags'), max_length=100)
    receiver = models.CharField(verbose_name=_('receiver'), max_length=100)
    origin = models.PointField(verbose_name=_('origin'))
    destination = models.PointField(verbose_name=_('destination'))
    insured = models.BooleanField(verbose_name=_('insured value'),
                                  default=False)
    price = models.DecimalField(verbose_name=_('price'),
                                max_digits=10,
                                decimal_places=2,
                                default=0)
    reputation = models.OneToOneField('Reputation',
                                      verbose_name=_('reputation'),
                                      null=True)
    status = models.ForeignKey('Status', verbose_name=_('status'))
    created_at = models.DateTimeField(verbose_name=_('created at'),
                                      auto_now_add=True,
                                      editable=False)
    updated_at = models.DateTimeField(verbose_name=_('updated at'),
                                      auto_now=True,
                                      editable=False)

    class Meta:
        verbose_name = _('shipment')
        verbose_name_plural = _('shipment')
Exemple #22
0
class PlaceImage(models.Model):
    class Meta:
        verbose_name = 'imagen'
        verbose_name_plural = 'imagenes'

    image = models.ImageField(upload_to='place_image', verbose_name='imagen')
    is_cover = models.BooleanField(default=False, verbose_name='de portada?')
    place = models.ForeignKey(Place,
                              on_delete=models.CASCADE,
                              related_name='images')
Exemple #23
0
class LocationSourceType(models.Model):
    name = models.CharField(max_length=255)
    icon = models.ImageField(
        null=True,
        blank=True,
        upload_to='source_type_icons/'
    )

    def __unicode__(self):
        return self.name
Exemple #24
0
class Product(models.Model):
    code = models.SlugField(max_length=8)
    name = models.CharField(max_length=150)
    description = models.TextField()
    short_desc = models.CharField(max_length=150)
    pics = models.ImageField(upload_to="media/product")
    price = models.FloatField(max_length=10)

    def __unicode__(self):
        return self.name
class AuctionImage(models.Model):
    auction = models.ForeignKey(Auction, related_name='images')
    image = models.ImageField(upload_to='auctions/')
    default = models.BooleanField(default=False)

    def __unicode__(self):
        return '{} Image'.format(self.auction.title)

    def __str__(self):
        return self.__unicode__()
Exemple #26
0
class Photo(TroggleImageModel):
    file = models.ImageField(storage=photoFileStorage,
                             upload_to='.',
                             null=False)
    caption = models.TextField(blank=True, null=True)
    slug = models.SlugField()
    contains_logbookentry = models.ForeignKey(LogbookEntry,
                                              blank=True,
                                              null=True)
    contains_person = models.ManyToManyField(Person, blank=True, null=True)
    is_mugshot = models.BooleanField(default=False)
    contains_cave = models.ForeignKey(
        Cave,
        blank=True,
        null=True,
        help_text='If you fill this out, do not fill out "location" below.')
    contains_entrance = models.ForeignKey(
        Entrance,
        related_name="photo_file",
        blank=True,
        null=True,
        help_text='If you fill this out, do not fill out "location" below.')
    nearest_survey_point = models.ForeignKey(
        SurveyStation,
        blank=True,
        null=True,
        help_text='If you fill this out, do not fill out "location" below.')
    nearest_QM = models.ForeignKey(
        QM,
        blank=True,
        null=True,
        help_text='If you fill this out, do not fill out "location" below.')
    taken_by = models.ForeignKey(Person,
                                 blank=True,
                                 null=True,
                                 related_name="photographer")
    location = models.PointField(
        blank=True,
        null=True,
        help_text=
        'Only fill this out if the photo is not linked to a cave, entrance, survey point, or QM. You can use the text field below to manually enter coordinates in the Well-Known Text format.'
    )
    objects = models.GeoManager()

    class IKOptions:
        spec_module = 'core.imagekit_specs'
        cache_dir = 'thumbs'
        image_field = 'file'

    #content_type = models.ForeignKey(ContentType)
    #object_id = models.PositiveIntegerField()
    #location = generic.GenericForeignKey('content_type', 'object_id')

    def __unicode__(self):
        return self.caption
Exemple #27
0
class Trail(models.Model):
    """Model definition of a Trail."""

    guid = models.UUIDField(_('GUID'),
                            db_index=False,
                            null=False,
                            default=uuid_lib.uuid4,
                            editable=False)

    name = models.CharField(_('Name of Trail'),
                            max_length=255,
                            help_text=_('Enter name of the Trail.'))

    notes = models.TextField(
        _("Notes on named Trail"),
        max_length=300,
        null=True,
        blank=True,
        help_text=_('Enter some notes regarding the above named trail'))

    image = models.ImageField(
        _('Image file'),
        null=True,
        blank=True,
        upload_to=os.path.join(MEDIA_ROOT, 'images/trail'),
        help_text=_(
            'An image of the trail. '
            'Most browsers support dragging the image directly on to the '
            '"Choose File" button above.'))

    colour = models.CharField(_("Colour"),
                              max_length=255,
                              null=True,
                              blank=True,
                              help_text=_('Enter colour hex of the trail.'))

    offset = models.IntegerField(_("Offset"),
                                 default=0,
                                 null=True,
                                 blank=True,
                                 help_text=_('Enter offset value i.e -2'))

    geometry = models.PointField(geography=True,
                                 blank=True,
                                 null=True,
                                 srid=4326)

    slug = models.SlugField()
    objects = models.Manager()

    def _str__(self):
        return self.__unicode__()

    def __unicode__(self):
        return '%s' % (self.name)
Exemple #28
0
class Poi(models.Model):
    "Misto - bod v mape"
    author = models.ForeignKey(User, verbose_name="Autor")
    created_at = models.DateTimeField(auto_now_add=True,  verbose_name="Posledni zmena")

    nazev   = models.CharField(max_length=255, verbose_name=u"název")   # Name of the location
    
    # Relationships
    znacka  = models.ForeignKey(Znacka, verbose_name=u"značka")          # "Znacky"   - misto ma prave jednu
    status  = models.ForeignKey(Status)          # "Statuty"  - misto ma prave jeden
    vlastnosti    = models.ManyToManyField('Vlastnost', blank=True, null=True)       # "Vlastnosti" - ma vice
    
    # "dulezitost" - modifikator minimalniho zoomu, ve kterem se misto zobrazuje. 
    dulezitost = models.SmallIntegerField(default=0, verbose_name=u"důležitost",
                 help_text=u"""Modifikátor minimalniho zoomu, ve kterém se místo zobrazuje (20+ bude vidět vždy). 
                               Cíl je mít výběr základních objektů viditelných ve velkých měřítcích
                               a zabránit přetížení mapy značkami v přehledce.
                               Lze použít pro placenou reklamu! ("Váš podnik bude vidět hned po otevření mapy")""")
    
    # Geographical intepretation
    geom    = models.PointField(verbose_name=u"poloha",srid=4326, help_text=u"Klikni na tužku s plusem a umisti bod na mapu")
    objects = models.GeoManager()
    
    # Own content (facultative)
    desc    = models.TextField(null=True, blank=True, verbose_name=u"popis", help_text=u"Text do buliny na mapě")
    desc_extra = models.TextField(null=True, blank=True, verbose_name=u"podrobný popis", help_text="Text do detailu místa (mimo bublinu)")
    url     = models.URLField(null=True, blank=True, help_text=u"Webový odkaz na stránku podniku apod.")
    address = models.CharField(max_length=255, null=True, blank=True, verbose_name=u"adresa")
    remark  = models.TextField(null=True, blank=True, verbose_name=u"interní poznámka", help_text=u"Interní informace o objektu, které se nebudou zobrazovat")

    # 3 fotografie museji pro vetsinu ucelu stacit
    foto_thumb  = models.ImageField(null=True, blank=True, upload_to='foto', verbose_name=u"foto", help_text=u"Velikost max. 500x400px") # 150 x 100 px
#    foto2 = models.ImageField(null=True, blank=True, upload_to='foto') 
#    foto3 = models.ImageField(null=True, blank=True, upload_to='foto') 
    
    # zde se ulozi slugy vsech vlastnosti, aby se pri renederovani kml
    # nemusel delat db dotaz pro kazde Poi na jeho vlastnosti
    vlastnosti_cache = models.CharField(max_length=255, null=True, blank=True)
    
    viditelne = ViditelneManager()
    
    class Meta:
        verbose_name = "místo"
        verbose_name_plural = "místa"
    def __unicode__(self):
        return self.nazev
    def save_vlastnosti_cache(self):
        self.vlastnosti_cache = u",".join([v.slug for v in self.vlastnosti.filter(status__show=True)])
        self.save()
    def get_absolute_url(self):
        return "/misto/%i/" % self.id

    def save(self, *args, **kwargs):
        self.created_at = datetime.datetime.now()
        super(Poi, self).save(*args, **kwargs)
Exemple #29
0
class Organization(models.Model):
    """
    Organization represents organizations with a user
    Fields included:
    - name: name of the organization
    - description: description of the organization
    - ext_link: external link to organization website
    - states: the states that the organization operates in
    - slug: internal representable link slug
    - members: members of the organization
    - verified: is the organization verified as legitimate by our team
    - government: is the organization a government (e.g. city, county, state commission)
    - logo: organization logo image
    - image_width and image_height: for calculating the image ratios
    """

    name = models.CharField(max_length=128)
    description = models.CharField(max_length=500, blank=True)
    ext_link = models.URLField(max_length=200, blank=True)
    states = ArrayField(
        models.CharField(max_length=50, choices=STATES, blank=True),
        blank=False,
    )
    slug = models.SlugField(unique=True, max_length=50)
    members = models.ManyToManyField(User, through="Membership")
    verified = models.BooleanField(default=False)
    government = models.BooleanField(default=False, blank=True, null=True)
    logo = models.ImageField(upload_to='images/', null=True, blank=True, verbose_name="") #, width_field='image_width', height_field='image_height')
    # image_width = models.IntegerField(blank=True, null=True)
    # image_height = models.IntegerField(blank=True, null=True)

    class Meta:
        ordering = ("description",)

    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        # generate the slug once the first time the org is created
        if not self.slug:
            # change self.name to be less than 35 char, split at a space,
            slug_slice = 35
            for idx, char in enumerate(self.name):
                if char == " " and idx < 35:
                    slug_slice = idx
            slug_name = self.name[:slug_slice]
            self.slug = generate_unique_slug(Organization, slug_name)
        super(Organization, self).save(*args, **kwargs)

    def get_url_kwargs(self):
        return {"pk": self.id, "slug": self.slug}

    def get_absolute_url(self):
        return reverse("main:home_org", kwargs=self.get_url_kwargs())
Exemple #30
0
class MainRepresentation(Media):
    picture = models.ImageField(upload_to=poi_directory_path, verbose_name="image principale")
    poi = models.OneToOneField(
        PointOfInterest,
        on_delete=models.CASCADE,
        primary_key=True,
    )

    class Meta:
        verbose_name = "image principale"
        verbose_name_plural = "images principales"