Ejemplo n.º 1
0
class CategorieAssociation(models.Model):
    name = models.CharField(max_length=512,
                            verbose_name=_("categorie"))
    parent = models.ForeignKey("self",
                               null=True,
                               blank=True)
    slug = models.SlugField(max_length=40,
                            null=True,
                            blank=True,
                            help_text=_("nom formaté pour les URLs"))
    slug = models.SlugField(null=True,
                            blank=True,
                            help_text=_("nom formaté pour les URLs"))
    region_child2 = models.ForeignKey(RegionChild2,
                                      null=True,
                                      blank=True,
                                      help_text=_("commune d'origine"),
                                      verbose_name=_("commune"))

    class Meta:
        verbose_name = _('categorie')
        verbose_name_plural = _('categorie')

    def __str__(self):
        return self.name
    def get_absolute_url(selfself):
        from django.core.urlresolvers import reverse
        return reverse()
    def save(self, **kwargs):
        from regionfestival.snippets import unique_slugify
        unique_slugify(self, self.name)
        super(CategorieAssociation, self).save(**kwargs)
Ejemplo n.º 2
0
class PostalCode(models.Model):
    """
    A postal code representing a general location.

    Shapes are sourced from ZIP code tabulation area data provided by
    the US Census Bureau.
    """

    objects = models.GeoManager()

    postal_code = models.CharField(max_length=7, unique=True)
    state = models.SlugField(max_length=255)
    country = models.SlugField(max_length=2, help_text='ISO 3166-1 alpha-2')
    market = models.ForeignKey(to=Market,
                               blank=True,
                               null=True,
                               related_name='postal_codes')
    community = models.ForeignKey(to=Community,
                                  blank=True,
                                  null=True,
                                  related_name='postal_codes')

    center = models.PointField(db_index=False)
    tabulation = models.MultiPolygonField(db_index=False)

    def __unicode__(self):
        return self.postal_code
Ejemplo n.º 3
0
class ObservationalStudy(models.Model):
    drugs = models.ManyToManyField(Drug, blank=True, verbose_name=_('drugs'))

    slug = models.SlugField(max_length=512, blank=True)
    drug_title = models.CharField(max_length=1024, blank=True)
    drug_slug = models.SlugField(max_length=1024, blank=True)
    description = models.TextField(blank=True)

    registration_date = models.DateField(blank=True, null=True)
    start_date = models.DateField(blank=True, null=True)
    end_date = models.DateField(blank=True, null=True)

    company = models.CharField(_('executing company'),
                               max_length=1024, blank=True)
    sponsor = models.CharField(_('sponsor'),
                               max_length=1024, blank=True)

    patient_count = models.IntegerField(null=True, blank=True)
    doc_count = models.IntegerField(null=True, blank=True)
    fee_per_patient = models.DecimalField(null=True, blank=True,
                                          decimal_places=2, max_digits=19)
    fee_description = models.TextField(blank=True)

    reference = models.CharField(max_length=1024, blank=True)

    objects = ObservationalStudyManager()

    class Meta:
        verbose_name = _('observational study')
        verbose_name_plural = _('observational studies')
        ordering = ('-start_date',)

    def __str__(self):
        return self.drug_title

    def natural_key(self):
        return (self.slug,)
    natural_key.dependencies = [
            'correctiv_eurosfueraerzte.Drug']

    @models.permalink
    def get_absolute_url(self):
        return ('eurosfueraerzte:eurosfueraerzte-studydetail', (), {
            'slug': self.slug
        })

    @property
    def is_running(self):
        if self.end_date is None:
            return True
        now = timezone.now().date()
        if self.end_date > now:
            return True
        return False
Ejemplo n.º 4
0
class City(models.Model):
    """Město"""
    class Meta:
        verbose_name = _("Město")
        verbose_name_plural = _("Města")
        ordering = ("name", )

    name = models.CharField(
        verbose_name=_("Jméno"),
        unique=True,
        max_length=40,
        null=False,
    )
    slug = models.SlugField(
        unique=True,
        verbose_name=_("Subdoména v URL"),
        blank=False,
    )
    wp_slug = models.SlugField(
        unique=True,
        verbose_name=_("Subdoména na WordPressu"),
        help_text=_("Pokud není vyplněno, použije se slug"),
        blank=True,
        null=True,
    )
    cyklistesobe_slug = models.SlugField(
        verbose_name=_("Jméno skupiny na webu Cyklisté sobě"),
        max_length=40,
        null=True,
    )
    location = models.PointField(
        verbose_name=_("poloha města"),
        srid=4326,
        null=True,
        blank=False,
    )

    def __str__(self):
        return "%s" % self.name

    def get_wp_slug(self):
        if self.wp_slug:
            return self.wp_slug
        return self.slug

    def get_wp_url(self):
        # TODO
        return "https://dopracenakole.cz/mesta/" + self.get_wp_slug()
Ejemplo n.º 5
0
class Theme(models.Model):
    """ A theme to guide and categorize user contributions and conversations"""

    title = models.CharField(max_length=100)
    slug = models.SlugField(max_length=100)
    desc = MarkupField(
        "Description",
        blank=True,
        null=True,
        help_text=
        "Use <a href='http://daringfireball.net/projects/markdown/syntax'>Markdown-syntax</a>"
    )

    class Meta:
        ordering = ("title", )

    def __unicode__(self):
        return u"%s" % self.title

    @permalink
    def get_absolute_url(self):
        return ("theme_detail", None, {
            "slug": self.slug,
        })

    def get_comment_count(self):
        return Comment.objects.for_model(self).count()
Ejemplo n.º 6
0
class Birds(models.Model):
    kingdom = models.CharField(max_length=40)
    phylum = models.ManyToManyField(Phylum, help_text='Select Phylum Name...')
    bird_class = models.ManyToManyField(Class,
                                        help_text='Select Class Name...')
    order = models.ManyToManyField(Order, help_text='Select Order Name...')
    family = models.ManyToManyField(Family, help_text='Select Family Name...')
    family_author = models.ManyToManyField(
        FamilyAuthor, help_text='Select Family Author name ... ')
    genus = models.ManyToManyField(Genus, help_text='Select Genus name ..')
    genus_author = models.ManyToManyField(
        GenusAuthor, help_text='Select Genus Author name ... ')
    scientific_name = models.CharField(max_length=50)
    scientific_name_author = models.CharField(max_length=40)
    year = models.PositiveIntegerField()
    status = models.ForeignKey(Status, on_delete=models.CASCADE)
    accepted_as = models.CharField(max_length=70)
    bengali_name = models.CharField(max_length=100)
    english_name = models.CharField(max_length=100)
    size_cm = models.PositiveIntegerField()
    common_family = models.CharField(max_length=40)
    common_group = models.CharField(max_length=40)
    habit = models.CharField(max_length=20)
    conservation_status = models.CharField(max_length=10)
    distribution_in_bengal = models.ManyToManyField(
        DistributionOfBengal, help_text='Select Place ..')
    reference = models.CharField(max_length=500)

    # class Birds(models.Model):
    #     kingdom = models.CharField(max_length=40)
    #     phylum = models.CharField(max_length=70)
    #     bird_class = models.CharField(max_length=70)
    #     order = models.CharField(max_length=70)
    #     family = models.CharField(max_length=70)
    #     family_author = models.CharField(max_length=70)
    #     genus = models.CharField(max_length=70)
    #     genus_author = models.CharField(max_length=70)
    #     scientific_name = models.CharField(max_length=50)
    #     scientific_name_author = models.CharField(max_length=40)
    #     year = models.IntegerField()
    #     status = models.CharField(max_length=70)
    #     accepted_as = models.CharField(max_length=70)
    #     bengali_name = models.CharField(max_length=100)
    #     english_name = models.CharField(max_length=100)
    #     size_cm = models.CharField(max_length=10)
    #     common_family = models.CharField(max_length=40)
    #     common_group = models.CharField(max_length=40)
    #     habit = models.CharField(max_length=20)
    #     conservation_status = models.CharField(max_length=10)
    #     distribution_in_bengal = models.CharField(max_length=70)
    #     reference = models.CharField(max_length=500)

    slug = models.SlugField()

    def save(self, *args, **kwargs):
        self.slug = slugify(self.kingdom)
        super(Birds, self).save(*args, **kwargs)

    def __str__(self):
        return self.kingdom
Ejemplo n.º 7
0
class Station(models.Model):
    """ A Greenline station """

    name = models.CharField(max_length=50)
    slug = models.SlugField(max_length=50)
    desc = MarkupField(
        "Description",
        blank=True,
        null=True,
        help_text=
        "Use <a href='http://daringfireball.net/projects/markdown/syntax'>Markdown-syntax</a>"
    )

    geometry = models.PointField(geography=True)  # default SRS 4326
    objects = models.GeoManager()

    class Meta:
        ordering = ("name", )

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

    @permalink
    def get_absolute_url(self):
        return ("station_area_detail", None, {
            "slug": self.slug,
        })
Ejemplo n.º 8
0
class TrailSections(models.Model):
    "Model definition of a Trail Sections."

    order = models.CharField(
        _('Order'),
        max_length = 255,
        null = False,
        blank = False,
        help_text = _('Enter ordering of trail sections.')
    )

    slug = models.SlugField(
        null=True,
        blank=True
    )

    objects = models.Manager()
    trail = models.ForeignKey(Trail)
    trail_section = models.ForeignKey(TrailSection)

    class Meta:
        ordering = ['order']
        app_label = 'trail'
        verbose_name_plural = 'Trail Sections'


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

    def __unicode__(self):
        return '%s' % (self.order)
Ejemplo n.º 9
0
class PharmaCompany(models.Model):
    name = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)

    sub_names = models.TextField(blank=True)

    web = models.CharField(max_length=1024, blank=True)
    payments_url = models.CharField(max_length=1024, blank=True)

    country = models.CharField(max_length=2, default='DE')

    search_vector = SearchVectorField(default='')

    objects = PharmaCompanyManager()

    class Meta:
        verbose_name = _('Pharma Company')
        verbose_name_plural = _('Pharma Companies')
        ordering = ('name',)

    def __str__(self):
        return self.name

    def natural_key(self):
        return (self.slug,)

    @models.permalink
    def get_absolute_url(self):
        return ('eurosfueraerzte:eurosfueraerzte-companydetail', (), {
            'slug': self.slug
        })

    def get_sub_names(self):
        return [x for x in self.sub_names.splitlines() if x]
Ejemplo n.º 10
0
class Station(models.Model):
    """
    A portal on the Metro Rail train system where riders can access
    a stop on the system.
    
    A station can host multiple stop,s like 7th Street / Metro Center
    holds separate stops for the Blue and Red lines.
    """
    name = models.CharField(max_length=100)
    slug = models.SlugField(blank=True, null=True)
    lines = models.ManyToManyField(Line, blank=True, null=True)
    
    class Meta:
        ordering = ('name',)
    
    def __unicode__(self):
        return self.name
    
    def get_line_display(self):
        from django.utils.text import get_text_list
        return get_text_list([i.name for i in self.lines.all()], 'and')
    get_line_display.short_description = 'Lines'
    
    def get_stop_count(self):
        return self.stop_set.count()
    get_stop_count.short_description = 'Stops'
Ejemplo n.º 11
0
class Provincia(models.Model):
    # Obligatorios
    nombre = models.CharField(max_length=100, blank=False, null=False)
    slug = models.SlugField(max_length=120, blank=True, null=False)

    # Opcionales
    variantes_nombre = models.CharField(max_length=150, blank=True, null=True)
    longitud_poligono = models.DecimalField(max_digits=7,
                                            decimal_places=2,
                                            blank=True,
                                            null=True)
    area_poligono = models.DecimalField(max_digits=7,
                                        decimal_places=2,
                                        blank=True,
                                        null=True)
    centro = models.PointField(blank=True, null=True)
    poligono = models.PolygonField(blank=True, null=True)

    objects = GeoManager()

    def save(self, *args, **kwargs):
        self.slug = slugify(self.nombre)
        if self.poligono:
            self.centro = self.poligono.centroid
        super(Provincia, self).save(*args, **kwargs)

    def __str__(self):
        return self.nombre
Ejemplo n.º 12
0
class Jurisdiction(models.Model):
    name = models.CharField(_("Name"), max_length=255)
    slug = models.SlugField(_("Slug"), max_length=255)
    description = models.TextField(_("Description"), blank=True)
    hidden = models.BooleanField(_("Hidden"), default=False)
    rank = models.SmallIntegerField(default=1)
    region = models.ForeignKey(
        GeoRegion, null=True, on_delete=models.SET_NULL, blank=True
    )

    objects = JurisdictionManager()

    class Meta:
        verbose_name = _("Jurisdiction")
        verbose_name_plural = _("Jurisdictions")
        ordering = ('rank', 'name',)

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('publicbody-show_jurisdiction',
            kwargs={'slug': self.slug})

    def get_absolute_domain_url(self):
        return "%s%s" % (settings.SITE_URL, self.get_absolute_url())

    def get_all_laws(self):
        laws = FoiLaw.objects.filter(jurisdiction=self)
        meta_ids = laws.filter(meta=True).values_list('combined', flat=True)
        meta_laws = FoiLaw.objects.filter(pk__in=meta_ids)
        return laws.union(meta_laws)
Ejemplo n.º 13
0
class Product(models.Model):
    category = models.ForeignKey(Category,
                                 related_name='product',
                                 on_delete=models.CASCADE)
    name = models.CharField(max_length=200, db_index=True)
    slug = models.SlugField(max_length=200, db_index=True)
    store = models.ForeignKey(Store,
                              related_name="store_product",
                              on_delete=models.CASCADE)
    image = models.ImageField(upload_to="products/%Y/%m/%d", blank=True)
    description = models.TextField(blank=True)
    processing_time = models.CharField(max_length=255)
    price = models.DecimalField(max_digits=10, decimal_places=2)
    stock = models.PositiveIntegerField(default=60)
    location = models.PointField()
    available = models.BooleanField(default=True)
    created = models.DateTimeField(auto_now_add=True)
    updated = models.DateTimeField(auto_now=True)

    objects = models.Manager()
    available_products = AvailableProductManager()

    class Meta:
        ordering = ('-created', )
        index_together = (('id', 'slug'), )

    def __str__(self):
        return self.name
Ejemplo n.º 14
0
class Location(TimeStampedModel):
    name = models.CharField(max_length=255, unique=True)
    slug = models.SlugField(max_length=255, unique=True)
    description = models.TextField(null=True, blank=True)
    notes = models.TextField(
        null=True,
        blank=True,
        help_text=
        'Are there special requirements for organizers at this location?')
    geo_location = models.PointField(srid=4326, blank=True, null=True)
    city = models.CharField(max_length=1000, null=True, blank=True)
    country = models.CharField(max_length=255, null=True, blank=True)
    homepage = models.URLField(max_length=128,
                               blank=True,
                               null=True,
                               help_text="URL of homepage (including http://)")

    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        if not self.id:
            self.slug = slugify(self.name)

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

    class Meta:
        ordering = ['slug']
Ejemplo n.º 15
0
class TourConfig(models.Model):
    tour_name = models.CharField(max_length=256)
    tour_logo = models.URLField(verbose_name='URL of tour logo')
    tour_id = models.SlugField(max_length=64, unique=True, db_index=True)
    tour_organization = models.CharField(max_length=256)
    dcs_url = models.URLField(verbose_name='URL of DCS')
    gcm_sender_id = models.CharField(max_length=64)
    start_time = models.PositiveIntegerField()
    max_tour_time = models.PositiveIntegerField()
    is_cancelled = models.BooleanField(default=False,
                                       verbose_name='Cancel the tour?')
    tour_route = models.ForeignKey('TourRoute',
                                   on_delete=models.PROTECT,
                                   blank=True,
                                   null=True)
    server_polling_rate = models.PositiveIntegerField(
        verbose_name='Server Polling Rate (sec)',
        default=600)  #Default time is 10 minutes in seconds
    location_polling_rate = models.PositiveIntegerField(
        verbose_name='Device Location Polling Rate (sec)',
        default=45)  #Default time is 45 sec in seconds
    server_polling_range = models.PositiveIntegerField(
        verbose_name='Server Polling Range (sec)', default=5)

    class Meta:
        verbose_name = 'tour'

    def __unicode__(self):
        return unicode(self.tour_name)
Ejemplo n.º 16
0
class Beach(models.Model):
    TYPES = (
        ('Beach', 'Beach'),
        ('Mountain', 'Mountain'),
        ('Cave', 'Cave'),
        ('Waterfall', 'Waterfall'),
        ('River', 'River'),
        ('Birdwatching', 'Birdwatching'),
    )

    name = models.CharField(max_length=255, unique=True)
    slug = models.SlugField()

    has_parking = models.BooleanField(default=False)
    cover = models.ImageField(upload_to='beach_images/', blank=True, null=True)
    description = MarkdownxField(null=True)
    location = models.PointField(null=True, blank=True)

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

    class Meta:
        ordering = ["name"]

    def __str__(self):
        return self.name
Ejemplo n.º 17
0
class Place(node_factory('PlaceRelation')):
    """
    A larger scale geographic area such as a neighborhood or zip code
    
    Places are related hierachically using a directed graph as a place can
    have multiple parents.

    """
    name = ShortTextField(_("Name"))
    geolevel = models.ForeignKey(GeoLevel,
                                 null=True,
                                 blank=True,
                                 related_name='places',
                                 verbose_name=_("GeoLevel"))
    boundary = models.MultiPolygonField(blank=True,
                                        null=True,
                                        verbose_name=_("Boundary"))
    place_id = UUIDField(auto=True, verbose_name=_("Place ID"), db_index=True)
    slug = models.SlugField(blank=True)

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

    def __unicode__(self):
        return self.name
Ejemplo n.º 18
0
class Legend(models.Model):
    "map legend items of underlay"
    name = models.CharField(unique=True,
                            max_length=255,
                            verbose_name=_(u"name"))
    en_name = models.CharField(unique=True,
                               max_length=255,
                               null=True,
                               verbose_name=_(u"English name"))
    slug = models.SlugField(unique=True, verbose_name=_(u"name in URL"))
    desc = models.TextField(null=True,
                            blank=True,
                            verbose_name=_(u"description"))
    image = models.ImageField(upload_to='ikony',
                              storage=SlugifyFileSystemStorage(),
                              verbose_name=_(u"image"))

    class Meta:
        verbose_name = _(u"legend item")
        verbose_name_plural = _(u"legend items")

    def __str__(self):
        return self.name

    def image_tag(self):
        return admin_image_widget.list_display(self.image)

    image_tag.allow_tags = True
    image_tag.short_description = _(u"image")
Ejemplo n.º 19
0
class DocumentType(models.Model):
    """
    Document category. Will be determined from the registered plugins.
    """
    name = models.SlugField(max_length=20, primary_key=True)
    # Plugins for this document type.
    definition = PluginField(plugins.DocumentPluginPoint,
                             related_name="definition")
    # Each document type must have exactly one indexer.
    indexer = PluginField(plugins.IndexerPluginPoint, related_name='indexer')
    # It can have any number of validators. It is strongly recommended to
    # provide at least one.
    validators = ManyPluginField(plugins.ValidatorPluginPoint, blank=True,
                                 related_name='validators')
    # Custom permissions upon retrieving data.
    retrieve_permissions = ManyPluginField(
        plugins.RetrievePermissionPluginPoint, blank=True,
        related_name='retrieve_permissions')
    # Same for uploading documents.
    upload_permissions = ManyPluginField(
        plugins.UploadPermissionPluginPoint, blank=True,
        related_name='upload_permissions')

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['name']
        verbose_name = 'Document Type'
        verbose_name_plural = 'Document Types'
Ejemplo n.º 20
0
class Region(models.Model):
    name = models.CharField(_("name"), max_length = 150)
    ascii_name = models.CharField(_("ASCII name"), max_length = 150)
    slug = models.SlugField(_("slug"), max_length = 50, unique = True, db_index = True)
    map_center = models.PointField(_("map center"))
    poly = models.PolygonField(_("poly"))
    population = models.PositiveIntegerField(_("population"), default = 0)

    objects = models.GeoManager()
    
    class Meta:
        verbose_name = _('Region')
        verbose_name_plural = _('Regions')
        ordering = ('-population', 'name',)
    
    def __unicode__(self):
        return self.name

    @property
    def add_realestate_link(self):        
        info = RealEstate._meta.app_label, RealEstate._meta.module_name
        pnt = self.map_center
        pnt.transform(3857)
        return '<a href="%s?%s">%s</a>' % (
            reverse('admin:realestate_realestate_add'),
            "lon=%s&amp;lat=%s" % pnt.coords,
            _("Add a Real Estate"), 
            )
Ejemplo n.º 21
0
class Vlastnost(models.Model):
    "Vlastnosti mist"
    nazev = models.CharField(max_length=255)  # Name of the property
    status = models.ForeignKey(
        Status, on_delete=models.CASCADE
    )  # "Statuty"  - tj. active/inactive. Mozny je i boolean "active"
    filtr = models.BooleanField()  # Pouzit v levem menu, filtrovat???
    poradi = models.PositiveIntegerField()
    # content
    slug = models.SlugField(unique=True,
                            verbose_name="Slug")  # Popis tagu v URL
    desc = models.TextField(null=True, blank=True)  # podrobny popis vlastnosti
    remark = models.TextField(
        null=True,
        blank=True,
        help_text=u"interni informace o objektu, ktere se nebudou zobrazovat")
    default_icon = models.ImageField(
        null=True, upload_to='ikony',
        storage=SlugifyFileSystemStorage())  # XXX: zrusit null=True

    class Meta:
        verbose_name_plural = u"vlastnosti"
        ordering = ['poradi']

    def __str__(self):
        return self.nazev
Ejemplo n.º 22
0
class Organisation(ModelBase):
    name = models.CharField(max_length=200)
    slug = models.SlugField(max_length=200,
                            unique=True,
                            help_text="created from name")
    summary = MarkupField(blank=True, default='')
    kind = models.ForeignKey('OrganisationKind')
    started = ApproximateDateField(blank=True, help_text=date_help_text)
    ended = ApproximateDateField(blank=True, help_text=date_help_text)
    original_id = models.PositiveIntegerField(
        blank=True,
        null=True,
        help_text=
        'temporary - used to link to parties in original mzalendo.com db')

    objects = OrganisationManager()
    contacts = generic.GenericRelation(Contact)

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

    @models.permalink
    def get_absolute_url(self):
        return ('organisation', [self.slug])

    class Meta:
        ordering = ["slug"]
Ejemplo n.º 23
0
class Facility(models.Model):
    name = models.CharField(max_length=200)
    slug = models.SlugField()
    short_name = models.CharField(max_length=50, blank=True)
    cms_id = models.CharField(max_length=6, blank=True, db_index=True)

    address = models.CharField(max_length=200)
    city = models.CharField(max_length=50)
    county = models.ForeignKey('County', on_delete=models.PROTECT)
    postal_code = models.CharField(max_length=10)
    phone = models.CharField(max_length=10)

    location = models.PointField(blank=True, null=True, geography=True)

    emergency_services = models.BooleanField()

    def save(self, *args, **kwargs):
        value = self.short_name if self.short_name else self.name
        self.slug = slugify(value, allow_unicode=True)
        super().save(*args, **kwargs)

    def get_absolute_url(self):
        kwargs = {
            'state_code': self.county.state.code,
            'county_slug': self.county.slug,
            'cms_id': self.cms_id,
            'slug': self.slug,
        }
        return reverse('facility', kwargs=kwargs)
Ejemplo n.º 24
0
class RW(Boundary):
    """RW Boundary."""

    class Meta:
        """Meta class."""
        app_label = 'flood_mapper'

    slug = models.SlugField(max_length=100)

    name = models.CharField(
        help_text='A name for the RW.',
        null=False,
        blank=False,
        unique=False,
        max_length=100
    )

    village = models.ForeignKey(Village)

    def __unicode__(self):
        return self.name

    def save(self, *args, **kwargs):
        """Overloaded save method."""
        self.slug = slugify(unicode(self.name))
        super(RW, self).save(*args, **kwargs)
Ejemplo n.º 25
0
class Section(OrderedModel):
    """A group of articles."""
    title = models.CharField(max_length=100)
    slug = models.SlugField()
    menu_item = models.BooleanField(
        default=True,
        help_text=
        'If set, this section will be shown in the menus at the top of the page.'
    )
    colour = models.CharField(blank=True, null=True, max_length=7)
    tag_name = models.CharField(
        max_length=100,
        default='Topics',
        help_text='The plural name given to a tag in this section.')
    editors = models.ManyToManyField(User, blank=True)
    email = models.EmailField(blank=True, null=True)

    objects = SectionManager()

    def get_absolute_url(self):
        return "/%s/" % self.slug

    def __unicode__(self):
        return u'%s' % self.title

    class Meta:
        ordering = [
            'order',
        ]
Ejemplo n.º 26
0
class Organization(models.Model):
    ORG_TYPE_CHOICES = (
        ('democratic', 'Democratic Party Organization'),
        ('governing-body', 'Governing Body'),
        ('progressive', 'Progressive Organization'),
        # ('advocacy', 'Advocacy Group'),
        # ('politician', 'Politician'),
        ('candidate', 'Political Candidate'),
    )
    title = models.CharField(max_length=255)
    url = models.URLField(blank=True)
    slug = models.SlugField(blank=True, null=True, max_length=255)
    organization_type = models.CharField(max_length=255,
                                         choices=ORG_TYPE_CHOICES,
                                         null=True,
                                         blank=True)
    objects = models.GeoManager()

    def __unicode__(self):
        return self.title

    def save(self, *args, **kwargs):
        if not self.slug:
            candidate_slug = slugify(self.title)[0:255]
            if self.__class__.objects.filter(slug=candidate_slug).exists():
                candidate_slug_counter = 1
                while True:
                    if not self.__class__.objects.filter(
                            slug="%s-%s" %
                        (candidate_slug, candidate_slug_counter)).exists():
                        break
                    candidate_slug_counter += 1

            self.slug = candidate_slug
        return super(Organization, self).save(*args, **kwargs)
Ejemplo n.º 27
0
class Map(Content):
    """
    Provides support for maps that can be attached to other content.
    """
    title = models.CharField(max_length=30)
    description = models.TextField()
    slug = models.SlugField(
        help_text="Used for URLs. Autogenerated from title.")
    section = models.ForeignKey(Section)

    mediatype = 'map'

    objects = models.GeoManager()

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        if self.section.publication.name == 'Columbia Prowl':
            return '/renters-guide/maps/%s/' % self.slug
        else:
            return '/maps/%s/' % self.slug

    class Meta:
        ordering = ['title']
Ejemplo n.º 28
0
class University(BaseModel):
    """大学を表すクラス"""
    slug = models.SlugField(max_length=32)

    class Meta:
        verbose_name = "大学"
        verbose_name_plural = "大学"
Ejemplo n.º 29
0
class BaseModel(models.Model):
    name = models.CharField(max_length=32)
    slug = models.SlugField(max_length=128, unique=True, blank=True)
    timestamp = models.DateTimeField(null=True, blank=True)
    geometry = models.GeometryField()
    objects = models.GeoManager()

    class Meta:
        abstract = True

    def __unicode__(self):
        return self.name

    def _generate_slug(self):
        if self.slug == '' or self.slug is None:
            try:
                name = unicode(self.name)
            except NameError:
                name = self.name
            self.slug = slugify(name)

    def clean(self):
        self._generate_slug()

    def save(self, *args, **kwargs):
        self._generate_slug()
        super(BaseModel, self).save(*args, **kwargs)
Ejemplo n.º 30
0
class Venue(models.Model):
    title = models.CharField(max_length=255)
    address = models.CharField(max_length=255)
    city = models.CharField(max_length=255)
    state = USStateField()
    zipcode = USZipCodeField(blank=True)
    slug = models.SlugField(blank=True, null=True, max_length=255)
    phone = PhoneNumberField(blank=True)
    url = models.URLField(blank=True)
    email = models.EmailField(blank=True)
    description = models.TextField(blank=True)
    keywords = models.CharField(blank=True, max_length=255)
    point = models.PointField(blank=True, null=True)
    objects = models.GeoManager()

    def save(self, *args, **kwargs):
        if not self.slug:
            candidate_slug = slugify(self.title)[0:255]
            if self.__class__.objects.filter(slug=candidate_slug).exists():
                candidate_slug_counter = 1
                while True:
                    if not self.__class__.objects.filter(
                            slug="%s-%s" %
                        (candidate_slug, candidate_slug_counter)).exists():
                        break
                    candidate_slug_counter += 1

            self.slug = candidate_slug
        if self.address and not self.point:
            self.point = Point(**get_point(', '.join(
                [self.address, self.city, self.state, self.zipcode])))
        return super(Venue, self).save(*args, **kwargs)

    def __unicode__(self):
        return self.title