예제 #1
0
class UserProfile(models.Model):
    '''Extension to Django's User model
    '''
    user = models.OneToOneField(User)
    avatar = ImageField(upload_to=settings.UPLOAD_AVATAR_FOLDER_MASK,
                        blank=True,
                        verbose_name='Photo or avatar')
    date_of_birth = models.DateField(blank=True, null=True)
    url = models.URLField(blank=True,
                          verify_exists=False,
                          verbose_name='Your website')
    sex = models.CharField(max_length=1, choices=SEXES, blank=True, null=True)
    physical_address = models.CharField(max_length=MAX_LENGTH, blank=True)
    physical_address_code = models.CharField(max_length=12, blank=True)
    physical_address_city = models.CharField(max_length=MAX_LENGTH, blank=True)
    physical_address_country = CountryField(blank=True)
    postal_address = models.CharField(max_length=MAX_LENGTH, blank=True)
    postal_address_code = models.CharField(max_length=12, blank=True)
    postal_address_city = models.CharField(max_length=MAX_LENGTH, blank=True)
    postal_address_country = CountryField(blank=True)

    @models.permalink
    def get_absolute_url(self):
        return ('profiles_profile_detail', (), {
            'username': self.user.username
        })

    def __unicode__(self):
        return self.user.username

    class Meta:
        verbose_name = _('user profile')
        verbose_name_plural = _('user profiles')
예제 #2
0
class DesignPersona(CommonModel):
    birth_year = models.IntegerField(u'שנת לידה', blank=True, null=True)
    death_year = models.IntegerField(u'שנת פטירה', blank=True, null=True)
    birth_country = CountryField(u'מדינת לידה', null=True,
                                 blank=True, default='IL')
    photo = models.ImageField(u'דיוקן', upload_to="images/", blank=True)
    philosophy = models.FileField(u'קובץ פילוסופיה',
                                  upload_to="pdf/", blank=True)
    cv = models.FileField(u'קורות חיים', upload_to="cv/", null=True, blank=True)
    is_active = models.BooleanField(u'מופיע באתר', default=False)
    philosophy_summary = HTMLField(u'תקציר פילוסופיה', blank=True)
    sidar_id = models.CharField(u'קוד', max_length=10)

    class Meta(CommonModel.Meta):
        abstract = True

    def available_categories_by_discipline(self, discipline):
        category_ids = self.work_set.filter(discipline=discipline)\
                                    .values_list('category', flat=True)\
                                    .distinct()
        return Category.objects.filter(pk__in=category_ids)

    def attached_files(self):
        """Only returns files attachments with files in them"""
        return [field for field in [self.cv, self.philosophy] if field]
예제 #3
0
class I4pProfile(UserenaLanguageBaseProfile):
    """
    Userena Profile with language switch
    """
    GENDER_TYPE = (
       ('M', _('male')),
       ('F', _('female'))
    )
    user = models.ForeignKey(User)
    gender = models.CharField(max_length=1, choices=GENDER_TYPE, null=True, blank=True)
    motto = models.TextField(_("motto"), null=True, blank=True)
    about = models.TextField(_("about"), null=True, blank=True)
    birthday = models.DateField(_("birthday"), null=True, blank=True)
    website = models.URLField(verbose_name=_('website'), verify_exists=True, max_length=200, blank=True)
    linkedin = models.URLField(verbose_name=_('linkedin'), verify_exists=True, max_length=200, blank=True)
    twitter = models.URLField(verbose_name=_('twitter'), verify_exists=True, max_length=200, blank=True)
    facebook = models.URLField(verbose_name=_('facebook'), verify_exists=True, max_length=200, blank=True)
    address = models.TextField(_("address"), null=True, blank=True)
    country = CountryField(_("country"), null=True, blank=True, choices=I4P_COUNTRIES)

    #FIXME:  USELESS ???
    location = models.OneToOneField(Location, verbose_name=_('location'), null=True, blank=True)
    
    @models.permalink
    def get_absolute_url(self):
        return ('userena_profile_detail', [self.user.username])
예제 #4
0
class BillingInfo(models.Model):
    """
    Stores customer billing data needed to issue an invoice
    """
    user = models.OneToOneField('auth.User', verbose_name=_('user'))
    name = models.CharField(_('name'), max_length=200, )
    street = models.CharField(_('street'), max_length=200)
    zipcode = models.CharField(_('zip code'), max_length=200)
    city = models.CharField(_('city'), max_length=200)
    country = CountryField(_("country"))
    tax_number = models.CharField(_('VAT ID'), max_length=200, blank=True)

    @staticmethod
    def clean_tax_number(tax_number, country):
        tax_number = re.sub(r'[^A-Z0-9]', '',  tax_number.upper())
        if tax_number and country:

            if country in vatnumber.countries():
                number = tax_number
                if tax_number.startswith(country):
                    number = tax_number[len(country):]

                if not vatnumber.check_vat(country + number):

#           This is a proper solution to bind ValidationError to a Field but it is not
#           working due to django bug :(
#                    errors = defaultdict(list)
#                    errors['tax_number'].append(_('VAT ID is not correct'))
#                    raise ValidationError(errors)
                    raise ValidationError(_('VAT ID is not correct'))

            return tax_number
        else:
            return ''
예제 #5
0
class UserProfile(models.Model):
    user = models.ForeignKey(User, related_name = 'profile', unique=True)
    title = models.CharField(max_length=5, choices=zip(TITLES, TITLES), null=True, blank=True)
    webpage = models.URLField(null=True, blank=True)
    display_email = models.BooleanField(default=True)
    institution = models.CharField(max_length=50, null=True, blank=True)
    institution_type = models.ForeignKey(InstitutionType, null=True, blank=True)
    institution_website = models.URLField(null=True, blank=True)
    country = CountryField(null=True, blank=True)
    research = models.TextField(null=True, blank=True)
    research_field = models.ManyToManyField(ResearchField)
    is_researcher = models.BooleanField(default=True)
    photograph = models.ImageField(upload_to=get_photo_path, null=True, blank=True)
    seabirds = models.ManyToManyField(SeabirdFamily, related_name='profiles', null=True, blank=True)
    twitter = models.CharField(max_length=15, null=True, blank=True)
    display_twitter = models.BooleanField(default=False)
    collaboration_choices = models.ManyToManyField(CollaborationChoice, null=True, blank=True)
    accept_terms = models.BooleanField(default=False)
    date_created = models.DateField(auto_now_add = True)
    date_updated = models.DateField(auto_now = True)
    wid = models.IntegerField(null=True, blank=True, editable=False)

    def __str__(self):
        return "%s %s"%(self.user.first_name, self.user.last_name)

    @models.permalink
    def get_absolute_url(self):
        return ('profiles_profile_detail', (), {'username': self.user.username})
예제 #6
0
class Venue(models.Model):
    name = models.CharField(max_length=255)
    street_address = models.TextField()
    country = CountryField()
    location = models.PointField(blank=True)

    objects = models.GeoManager()

    def __init__(self, *args, **kwargs):
        super(Venue, self).__init__(*args, **kwargs)
        if self.location is None:
            longitude = float(kwargs.get('longitude', '0'))
            latitude = float(kwargs.get('latitude', '0'))
            self.location = geos.Point(longitude, latitude)

    def __unicode__(self):
        return '%s - %s, %s' % (self.name, self.street_address, self.country)

    @property
    def latitude(self):
        return self.location.y

    @latitude.setter
    def latitude(self, value):
        self.location.y = value

    @property
    def longitude(self):
        return self.location.x

    @longitude.setter
    def longitude(self, value):
        self.location.x = value
예제 #7
0
class Estudiante(models.Model):
    def thumbnail(self):
        if self.avatar:
            return '<a href="/media/%s"><img src="/media/%s" width=150/></a>' % (
                self.avatar, self.avatar)
        else:
            return '(Sin Imagen)'

    thumbnail.short_description = ''
    thumbnail.allow_tags = True

    cod_rude = models.CharField(max_length=20,
                                primary_key=True,
                                verbose_name=u'Codigo Rude')
    nombres = models.CharField(max_length=100)
    apellidos = models.CharField(max_length=50)
    curso = models.ForeignKey(Clase, related_name='Pertenece a una clase')
    nombre_usuario = models.CharField(max_length=50)
    password = models.CharField(max_length=50)
    avatar = models.ImageField(upload_to='educar', verbose_name='Foto')
    fecha_nacimiento = models.DateField()
    telefono = models.CharField(max_length=50)
    #Declaramos nuestra funcion con las opciones declaradas en GENERO_CHOICES
    sexo = models.CharField(max_length=15, choices=GENERO_CHOICES, default='F')
    #Declaramos Countryfield para obtener los paises
    nacionalidad = CountryField()

    def __unicode__(self):
        #Primero concatenamos para obtener el nombre completo de de una persona
        nombrecompleto = "%s %s" % (self.nombres, self.apellidos)
        return nombrecompleto
예제 #8
0
파일: models.py 프로젝트: fidget77/test
class CheckLocation(models.Model):
    hostname = models.CharField(max_length=255)
    source_ip = models.GenericIPAddressField(verbose_name='source IP',
                                             unpack_ipv4=True,
                                             unique=True)
    country = CountryField()
    created = models.DateTimeField(editable=False)

    class Meta:
        ordering = ('hostname', 'source_ip')

    def __unicode__(self):
        return self.hostname

    @property
    def family(self):
        info = socket.getaddrinfo(self.source_ip, None, 0, 0, 0,
                                  socket.AI_NUMERICHOST)
        families = [x[0] for x in info]
        return families[0]

    @property
    def ip_version(self):
        '''Returns integer '4' or '6'.'''
        if self.family == socket.AF_INET6:
            return 6
        if self.family == socket.AF_INET:
            return 4
        return None
예제 #9
0
class UserProfile(models.Model):
    user = models.OneToOneField(User)
    profile_pic = models.ImageField(upload_to=UPLOAD_DIR,
                                    blank=True,
                                    default='icons/user.png')
    age = models.IntegerField(null=True, blank=True)
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES, blank=True)
    school = models.CharField(max_length=128,
                              choices=SCHOOL_CHOICES,
                              blank=True)
    country = CountryField(blank=True)
    city = models.CharField(max_length=128, blank=True)
    xp = models.IntegerField(default=0, blank=True)
    level = models.IntegerField(default=0, blank=True)
    xp_to_next_level = models.IntegerField(default=1, blank=True)
    last_time_played = models.DateTimeField(null=True, blank=True)
    no_games_played = models.IntegerField(default=0, blank=True)
    rank = models.IntegerField(default=0, blank=True)
    no_queries_issued = models.IntegerField(default=0, blank=True)
    no_successful_queries_issued = models.IntegerField(default=0, blank=True)

    def __unicode__(self):
        return self.user.username

    class Meta:
        app_label = APP_NAME
예제 #10
0
파일: models.py 프로젝트: xemuj/crowdata
class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    name = models.CharField(_('Your Name'), max_length='128', null=False, blank=False)
    country = CountryField(_('Your country'), null=True)
    current_organization = models.ForeignKey(Organization, blank = True, null = True)
    show_in_leaderboard = models.BooleanField(_("Appear in the leaderboards"),
                                              default=True,
                                              help_text=_("If checked, you will appear in CrowData's leaderboards"))
예제 #11
0
class UserProfile(models.Model):
    notify = models.BooleanField(
        "Send notifications",
        default=True,
        help_text="When enabled, send user 'flag out-of-date' notifications")
    time_zone = models.CharField(max_length=100,
                                 choices=make_choice(pytz.common_timezones),
                                 default="UTC",
                                 help_text="Used for developer clock page")
    alias = models.CharField(max_length=50, help_text="Required field")
    public_email = models.CharField(max_length=50, help_text="Required field")
    other_contact = models.CharField(max_length=100, null=True, blank=True)
    pgp_key = PGPKeyField(
        max_length=40,
        null=True,
        blank=True,
        verbose_name="PGP key fingerprint",
        help_text="consists of 40 hex digits; use `gpg --fingerprint`")
    website = models.CharField(max_length=200, null=True, blank=True)
    yob = models.IntegerField("Year of birth", null=True, blank=True)
    country = CountryField(blank=True)
    location = models.CharField(max_length=50, null=True, blank=True)
    languages = models.CharField(max_length=50, null=True, blank=True)
    interests = models.CharField(max_length=255, null=True, blank=True)
    occupation = models.CharField(max_length=50, null=True, blank=True)
    roles = models.CharField(max_length=255, null=True, blank=True)
    favorite_distros = models.CharField(max_length=255, null=True, blank=True)
    picture = models.FileField(upload_to='devs',
                               default='devs/silhouette.png',
                               help_text="Ideally 125px by 125px")
    user = models.OneToOneField(User, related_name='userprofile')
    allowed_repos = models.ManyToManyField('main.Repo', blank=True)
    latin_name = models.CharField(
        max_length=255,
        null=True,
        blank=True,
        help_text="Latin-form name; used only for non-Latin full names")
    last_modified = models.DateTimeField(editable=False)

    class Meta:
        db_table = 'user_profiles'
        get_latest_by = 'last_modified'
        verbose_name = 'additional profile data'
        verbose_name_plural = 'additional profile data'

    def get_absolute_url(self):
        # TODO: this is disgusting. find a way to consolidate this logic with
        # public.views.userlist among other places, and make some constants or
        # something so we aren't using copies of string names everywhere.
        group_names = self.user.groups.values_list('name', flat=True)
        if "Developers" in group_names:
            prefix = "developers"
        elif "Trusted Users" in group_names:
            prefix = "trustedusers"
        else:
            prefix = "fellows"
        return '/%s/#%s' % (prefix, self.user.username)
예제 #12
0
class Contact(Model):
    """This defines the Contact

    **Attributes**:

        * ``contact`` - Contact no
        * ``last_name`` - Contact's last name
        * ``first_name`` - Contact's first name
        * ``email`` - Contact's e-mail address
        * ``city`` - city name
        * ``description`` - description about a Contact
        * ``status`` - contact status
        * ``additional_vars`` - Additional variables

    **Relationships**:

        * ``phonebook`` - Foreign key relationship to the Phonebook model.\
        Each contact mapped with a phonebook
        * ``country`` - Foreign key relationship to the Country model.\
        Each contact mapped with a country

    **Name of DB table**: dialer_contact
    """
    phonebook = models.ForeignKey(Phonebook, verbose_name=_('Phonebook'),
                                help_text=_("Select Phonebook"))
    contact = models.CharField(max_length=90, verbose_name=_('Contact Number'))
    last_name = models.CharField(max_length=120, blank=True, null=True,
                                 verbose_name=_('Last Name'))
    first_name = models.CharField(max_length=120, blank=True, null=True,
                                  verbose_name=_('First Name'))
    email = models.EmailField(blank=True, null=True, verbose_name=_('Email'))
    country = CountryField(blank=True, null=True, verbose_name=_('Country'))
    city = models.CharField(max_length=120, blank=True, null=True,
                            verbose_name=_('City'))
    description = models.TextField(null=True, blank=True,
                  help_text=_("Contact Notes"))
    status = models.IntegerField(choices=CONTACT_STATUS, default='1',
                verbose_name=_("Status"), blank=True, null=True)
    additional_vars = models.CharField(max_length=100, blank=True,
                      verbose_name=_('Additional parameters'))
    created_date = models.DateTimeField(auto_now_add=True,
                   verbose_name=_('Date'))
    updated_date = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = u'dialer_contact'
        verbose_name = _("Contact")
        verbose_name_plural = _("Contacts")

    def __unicode__(self):
        return u"%s (%s)" % (self.contact, self.last_name)

    def contact_name(self):
        """Return Contact Name"""
        return u"%s %s" % (self.first_name, self.last_name)
    contact_name.allow_tags = True
    contact_name.short_description = _('Name')
예제 #13
0
class Entity(models.Model):
    name = models.CharField(max_length=200, unique=True)
    date_added = models.DateTimeField(editable=False, auto_now_add=True)
    date_last_edited = models.DateTimeField(editable=False, auto_now=True)
    type = models.ForeignKey(ClaimantType)

    # Physical address
    physical_address = models.CharField(max_length=200, blank=True)
    physical_city = models.CharField(max_length=200, blank=True)
    physical_country = CountryField(blank=True)
    physical_code = models.CharField(max_length=12, blank=True)

    # Postal address
    postal_address = models.CharField(max_length=200, blank=True)
    postal_city = models.CharField(max_length=200, blank=True)
    postal_country = CountryField(blank=True)
    postal_code = models.CharField(max_length=12, blank=True)

    website = models.URLField(blank=True, verify_exists=False)

    slug = models.SlugField(unique=True)
    further_reading = models.ManyToManyField(FurtherReading, blank=True, null=True,
                                verbose_name=_('further reading'))
    notes = models.TextField(blank=True)

    tags = TagField(help_text=_('Comma separated list of tags. '
                                'E.g. "huge quack", international etc.'
                                'Each tag must start with a letter and can contain '
                                'letters, digits, spaces and underscores.'))


    def describe(self):
        if self.notes:
            return self.notes
        else:
            return ""


    def __unicode__(self):
        return self.name

    class Meta:
        abstract = True
        ordering = ['name',]
예제 #14
0
파일: models.py 프로젝트: mrcrgl/stockstore
class StockExchange(models.Model):
    currency = models.ForeignKey(Currency, verbose_name="Currency")
    name = models.CharField(max_length=30, verbose_name="Name")
    symbol_yahoo = models.CharField(max_length=30, verbose_name="Symbol (Yahoo)", blank=True)
    suffix_yahoo = models.CharField(max_length=30, verbose_name="Suffix (Yahoo)", blank=True)
    symbol_finanzennet = models.CharField(max_length=30, verbose_name="Symbol (finanzen.net)", blank=True)
    country = CountryField(verbose_name="Country", default="DE")

    def __unicode__(self):
        return self.name
예제 #15
0
class Opening(TimeStampedModel):
    EMPLOYMENT_TYPES = Choices(
        ('part_time', _('Part Time')),
        ('full_time', _('Full Time')),
        ('internship', _('Internship')),
    )

    title = models.CharField(max_length=770)
    description = models.TextField()
    is_private = models.BooleanField(default=False)
    department = models.CharField(_("Department"), max_length=128, blank=True)
    country = CountryField(_("Country"), blank=True)
    city = models.CharField(_("City"), max_length=128, blank=True)
    published_date = models.DateTimeField(blank=True, null=True)
    employment_type = models.CharField(choices=EMPLOYMENT_TYPES,
                                       default=EMPLOYMENT_TYPES.full_time,
                                       max_length=20)

    company = models.ForeignKey(Company)

    def stage_counts(self):
        for stage in InterviewStage.objects.filter(company=self.company):
            yield self.application_set.filter(current_stage=stage).count()

    def get_apply_url(self):
        company_prefix = (settings.COMPANY_URL_PREFIX % self.company.subdomain)
        return "%s%s" % (company_prefix,
                         reverse('public:apply', args=(self.id, )))

    def get_location_string(self):
        location = ''

        if self.city:
            location += '%s' % self.city
            if self.country:
                location += ', '

        if self.country:
            location += '%s' % unicode(self.country.name)
        return location

    def get_status(self):
        if self.is_private:
            return _('Private')

        if self.published_date:
            return _('Published')

        return _('Created')

    def __str__(self):
        return '%s' % self.title
예제 #16
0
class Router(models.Model):
    def __unicode__(self):
        return self.user.email

    user = models.ForeignKey(User)
    isp = models.CharField(max_length=100)
    city = models.CharField(max_length=100)
    state = models.CharField(max_length=100)
    country = CountryField()
    service_type = models.CharField(max_length=100)
    service_plan = models.CharField(max_length=100)
    drate = models.CharField(max_length=100, blank=True)
    urate = models.CharField(max_length=100, blank=True)
예제 #17
0
class Location(models.Model):
    STATUS = (
        (0,'active'),
        (1,'deactivated'),
    )
    name = models.CharField(max_length=45, unique=True, verbose_name=_('Name'))
    street = models.CharField(max_length=255, verbose_name=_('Street'))
    postcode = models.CharField(max_length=12, verbose_name=_('Postcode'))
    city = models.CharField(max_length=255, verbose_name=_('City'))
    country = CountryField(verbose_name=_('Country'))
    customer = models.ForeignKey(Customer, to_field='id', db_column='idcustomer', related_name='location_customer', null=True, blank=True, verbose_name=_('Customer'))
    status = models.IntegerField(choices=STATUS, default=0)
    def __unicode__(self):
        return self.name
예제 #18
0
파일: models.py 프로젝트: archhurd/archweb
class MirrorUrl(models.Model):
    url = models.CharField("URL", max_length=255, unique=True)
    protocol = models.ForeignKey(MirrorProtocol,
                                 related_name="urls",
                                 editable=False,
                                 on_delete=models.PROTECT)
    mirror = models.ForeignKey(Mirror, related_name="urls")
    country = CountryField(blank=True, db_index=True)
    has_ipv4 = models.BooleanField("IPv4 capable",
                                   default=True,
                                   editable=False)
    has_ipv6 = models.BooleanField("IPv6 capable",
                                   default=False,
                                   editable=False)

    def address_families(self):
        hostname = urlparse(self.url).hostname
        info = socket.getaddrinfo(hostname, None, 0, socket.SOCK_STREAM)
        families = [x[0] for x in info]
        return families

    @property
    def hostname(self):
        return urlparse(self.url).hostname

    @property
    def real_country(self):
        return self.country or self.mirror.country

    def clean(self):
        try:
            # Auto-map the protocol field by looking at the URL
            protocol = urlparse(self.url).scheme
            self.protocol = MirrorProtocol.objects.get(protocol=protocol)
        except Exception as e:
            raise ValidationError(e)
        try:
            families = self.address_families()
            self.has_ipv4 = socket.AF_INET in families
            self.has_ipv6 = socket.AF_INET6 in families
        except socket.error as e:
            # We don't fail in this case; we'll just set both to False
            self.has_ipv4 = False
            self.has_ipv6 = False

    def __unicode__(self):
        return self.url

    class Meta:
        verbose_name = 'mirror URL'
예제 #19
0
class Clients(models.Model):
    id = models.AutoField(primary_key=True, db_column="id_client")
    users = models.ManyToManyField('Users', through='Clients2Users')
    name = models.CharField(_('Company name'),
                            unique=True,
                            max_length=255,
                            db_column="nom")
    zip = models.CharField(_('Postal code'), max_length=10, db_column="cp")
    city = models.CharField(_('City'), max_length=100, db_column="ville")
    addr1 = models.CharField(_('Address 1'), max_length=265)
    addr2 = models.CharField(_('Address 2'), max_length=265, blank=True)
    addr3 = models.CharField(_('Address 3'), max_length=265, blank=True)
    country = CountryField(_('Country'), max_length=50, db_column="pays")
    phone = models.CharField(_('Phone'),
                             max_length=15,
                             blank=True,
                             db_column="tel")
    fax = models.CharField(_('Fax'), max_length=200, blank=True)
    web = models.CharField(_('Website'), max_length=100, blank=True)
    vat_number = models.CharField(_('VAT number'),
                                  max_length=40,
                                  blank=True,
                                  null=True)
    #has_unpaid = models.NullBooleanField(_('Has unpaid'), default=False)
    #ca_total_ht = models.DecimalField(_('Total turnover'), null=True, max_digits=22, decimal_places=4, blank=True)
    #ca_total_ht_year = models.DecimalField(_('Total pre-taxed turnover'), null=True, max_digits=22, decimal_places=4, blank=True)
    #has_devis = models.NullBooleanField(_('Has quote?'), default=False)
    email = models.EmailField(_('Email'), max_length=255, blank=True)
    siren = models.CharField(_('Siren'), max_length=50, blank=True)
    #total_du_ht = models.DecimalField(_('Amount of duty'), null=True, max_digits=22, decimal_places=4, blank=True)
    company_type = models.ForeignKey('CompanyTypes',
                                     verbose_name=_('Company type'),
                                     db_column='id_company_type',
                                     default=1)
    # This is the user who created this I guess
    id_user = models.ForeignKey(Users,
                                verbose_name=_('User'),
                                related_name='creator',
                                db_column='id_user')  #models.IntegerField()
    password = models.CharField(_('Password'), max_length=300, blank=True)

    class Meta:
        verbose_name = _('Customer')
        verbose_name_plural = _('Customers')
        db_table = u'webfinance_clients'

    def __unicode__(self):
        return u"%s" % (unicode(self.name))
예제 #20
0
class Location(models.Model):
    name = models.CharField(_("Location Name"), max_length=100)
    description = models.TextField(_("Description"))

    website = models.URLField(_("Website"), blank=True)
    email = models.EmailField(_("Email"))
    phone = models.CharField(max_length=15, blank=True)

    addr_country_code = CountryField(_("Country"))
    addr_city = models.CharField(_("City"), max_length=50)
    addr_street = models.CharField(_("Street"), max_length=100)

    map_link = models.URLField(_("Map Link"))

    def __unicode__(self):
        return u"Location: %s" % self.name
예제 #21
0
class Proctor(models.Model):
    """This is where we store all the user demographic fields. We have a
    separate table for this rather than extending the built-in Django auth_user.

    Some of the fields are legacy ones that were captured during the initial
    MITx fall prototype.
    """
    class Meta:
        db_table = "auth_userproctor"

    # CRITICAL TODO/SECURITY
    # Sanitize all fields.
    # This is not visible to other users, but could introduce holes later
    user = models.OneToOneField(User,
                                unique=True,
                                editable=False,
                                db_index=True,
                                related_name='proctor')
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    title = models.CharField(max_length=255)

    relationship_to_student = models.CharField(max_length=255)
    email = models.EmailField(max_length=75)
    phone = models.CharField(max_length=23)
    fax = models.CharField(blank=True, max_length=23)
    street_address_1 = models.CharField(max_length=511)
    street_address_2 = models.CharField(blank=True, max_length=511)
    city = models.CharField(max_length=255)
    state = models.CharField(blank=True, max_length=127)
    zip_code = models.CharField(blank=True, max_length=255)
    country = CountryField()

    meta = models.TextField(
        blank=True, editable=False)  # JSON dictionary for future expansion

    def get_meta(self):
        js_str = self.meta
        if not js_str:
            js_str = dict()
        else:
            js_str = json.loads(self.meta)

        return js_str

    def set_meta(self, js):
        self.meta = json.dumps(js)
예제 #22
0
파일: models.py 프로젝트: Yerkhan01/SEPI
class Evento(models.Model):
    Nombre = models.CharField(
        max_length=250,
        verbose_name="Nombre Completo del Evento",
    )
    Pagina = models.URLField(max_length=500,
                             verbose_name="Web *Opcional",
                             null=True,
                             blank=True)
    Tipo = models.ForeignKey(TipoEvento)
    Costo = models.CharField(max_length=100, verbose_name="Costo")
    Descripcion = models.TextField(max_length=100,
                                   verbose_name="Breve descripción del evento")
    Fecha_I = models.DateField(auto_now=False, verbose_name="Fecha de inicio")
    Hora_I = models.TimeField(auto_now=False,
                              verbose_name="Hora de inicio *Opcional",
                              null=True,
                              blank=True)
    Fecha_F = models.DateField(auto_now=False,
                               verbose_name="Fecha de Finalización *Opcional",
                               null=True,
                               blank=True)
    Hora_F = models.TimeField(auto_now=False,
                              verbose_name="Hora de finalización *Opcional",
                              null=True,
                              blank=True)
    Pais = CountryField(verbose_name="Pais")
    Estado = models.CharField(max_length=100,
                              verbose_name="Estado, Provincia o Región")
    Municipio = models.CharField(max_length=100,
                                 verbose_name="Municipio, Delegación o Ciudad")
    Direccion = models.TextField(verbose_name="Domicilio")
    Referencias = models.TextField(
        verbose_name="Referencias y/o Detalles *Opcional",
        null=True,
        blank=True)
    Director = models.CharField(max_length=100,
                                verbose_name="Director del evento *Opcional",
                                null=True,
                                blank=True)
    Correo = models.EmailField(max_length=100,
                               verbose_name="E-mail de contacto")
    Validado = models.BooleanField(blank="True")

    def __unicode__(self):
        return self.Nombre + ' ' + str(self.Fecha_I) + ', Validado :' + str(
            self.Validado)
예제 #23
0
class Customer(models.Model):
    STATUS = (
        (0,'active'),
        (1,'deactivated'),
    )
    name = models.CharField(max_length=45, unique=True, verbose_name=_('Name'))
    street = models.CharField(max_length=255, verbose_name=_('Street'))
    postcode = models.CharField(max_length=12, verbose_name=_('Postcode'))
    city = models.CharField(max_length=255, verbose_name=_('City'))
    country = CountryField(verbose_name=_('Country'))
    status = models.IntegerField(choices=STATUS, default=0, verbose_name=_('Status'))
    def __unicode__(self):
        return self.name
    def projects(self):
        return Project.objects.filter(customer = self).exclude(name = 'Vacation').exclude(name = 'Ill')
    def active_projects(self):
        return Project.objects.filter(customer = self, status = 1)
예제 #24
0
class PostalAddress(models.Model):
    """
    Class representing postal address.
    """
    address = models.CharField(_(u"Address"), max_length=256)
    city = models.CharField(_(u"City"), max_length=64, default="Budapest")
    state = models.CharField(_(u"State or province"),
                             max_length=64,
                             blank=True)
    zip_code = models.CharField(_(u"zip code"), max_length=16)
    country = CountryField()

    def __unicode__(self):
        if not self.state:
            state = "N/A"

        return "%s %s, %s, %s %s, %s" % (self.zip_code, self.city,
                                         self.address_1, self.address_2, state,
                                         self.country)
예제 #25
0
class Location(models.Model):
    """
    A generic location model designed to be used to localize any object
    """
    lat = models.FloatField(verbose_name=_('latitude'), null=True, blank=True)

    lon = models.FloatField(verbose_name=_('longitude'), null=True, blank=True)

    country = CountryField(verbose_name=_('country'),
                           choices=I4P_COUNTRIES,
                           null=True,
                           blank=True)

    address = models.TextField(verbose_name=_('address'),
                               null=True,
                               blank=True)

    def __unicode__(self):
        return u"%s %s (%s, %s)" % (self.address, self.get_country_display(),
                                    self.lon, self.lat)
예제 #26
0
class Artist(models.Model):
    class Meta:
        verbose_name = u'Artista'
        verbose_name_plural = u'Artistas'
        ordering = [
            'name',
        ]

    name = models.CharField(u'nombre', max_length=255)
    country = CountryField(u'país', blank=True, null=True)
    image = models.ImageField(u'imagen del artista',
                              upload_to='uploads/artists',
                              blank=True,
                              null=True)

    #official_site = models.URLField(blank=True)
    #youtube_profile = models.URLField(blank=True)
    #wikipedia = models.URLField(u'wikipedia', blank=True)

    def __unicode__(self):
        return u"%s" % self.name
예제 #27
0
class DashboardModel(models.Model):
    date_from = models.DateField()
    date_to = models.DateField()
    country = CountryField(null=True)
    hash = models.CharField(max_length=32, blank=True)
    email = models.CharField(blank=True, max_length=200)
    data = models.TextField(blank=True)

    def format_date_from(self, obj):
        return obj.date.strftime('%m.%d.%Y')

    def format_date_to(self, obj):
        return obj.date.strftime('%m.%d.%Y')

    @property
    def dates(self):
        day = self.date_to.day - self.date_from.day
        return [
            self.date_from + datetime.timedelta(days=x)
            for x in range(0, day + 1)
        ]
예제 #28
0
class Location(geomodels.Model):
    """
    A generic location model designed to be used to localize any object
    """
#     lat = models.FloatField(verbose_name=_('latitude'),
#                             null=True, blank=True)
# 
#     lon = models.FloatField(verbose_name=_('longitude'),
#                             null=True, blank=True)

    country = CountryField(verbose_name=_('country'), choices=I4P_COUNTRIES,
                           null=True,
                           blank=True,
                           help_text=_(u"The country this location is in.  Set before geocoding,you'll get more accurate results")
                           )

    address = models.TextField(verbose_name=_('address'),
                               null=True,
                               blank=True,
                               help_text=_(u'The textual description of the Location to be displayed to the user.  Typically a full address such as \"880 rue Roy Est, espace 300 - Montréal (Québec) H2L 1E6)\", but can also be a less precise description of a location "Lake Champlain, Canada", or the name of a place location \"Museum of Fine Arts, Montréal, Québec, Canada\"')
                               )

    geom = geomodels.PointField(verbose_name=_('map'),
                                null=True,
                                blank=True,
                                help_text=_(u"You can chose a point on the map manually, or refine the one that was geocoded")
                                )
    objects = geomodels.GeoManager()
    
    @property
    def full_addr(self):
        addr = u""
        if self.address:
            addr += "%s," % self.address
        if self.country:
            addr += self.get_country_display()
        return addr
    
    def __unicode__(self):
        return self.full_addr
예제 #29
0
class Profesor(models.Model):

    #Vamos a crear un thumbnail para las imagenes

    def thumbnail(self):
        if self.foto:
            return '<a href="/media/%s"><img src="/media/%s" width=150/></a>' % (
                self.foto, self.foto)
        else:
            return '(Sin Imagen)'

    thumbnail.short_description = ''
    thumbnail.allow_tags = True

    ci = models.CharField(max_length=10,
                          primary_key=True,
                          verbose_name=u'Cedula de Identidad')
    nombres = models.CharField(max_length=100, verbose_name=u'Nombres')
    apellidos = models.CharField(max_length=50, verbose_name=u'apellidos')
    nombre_usuario = models.CharField(max_length=50)
    password = models.CharField(max_length=50)
    correo_electronico = models.EmailField(max_length=75)
    celular = models.CharField(max_length=50)
    foto = ImageField(upload_to='educar', verbose_name='Foto')
    #Declaramos nuestra funcion con las opciones declaradas en GENERO_CHOICES
    sexo = models.CharField(max_length=15, choices=GENERO_CHOICES, default='F')
    #Declaramos Countryfield para obtener los paises
    nacionalidad = CountryField()

    def __unicode__(self):
        #Primero concatenamos para obtener el nombre completo de de una persona
        nombrecompleto = "%s %s" % (self.nombres, self.apellidos)
        return nombrecompleto

    #La siguiente clase me permite cambiar el nombre de la clase en el Django Admin
    class Meta:
        verbose_name = u'Docente'
        verbose_name_plural = 'Docentes'
예제 #30
0
파일: models.py 프로젝트: archhurd/archweb
class Mirror(models.Model):
    TIER_CHOICES = (
        (0, 'Tier 0'),
        (1, 'Tier 1'),
        (2, 'Tier 2'),
        (-1, 'Untiered'),
    )

    name = models.CharField(max_length=255, unique=True)
    tier = models.SmallIntegerField(default=2, choices=TIER_CHOICES)
    upstream = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
    country = CountryField(blank=True, db_index=True)
    admin_email = models.EmailField(max_length=255, blank=True)
    alternate_email = models.EmailField(max_length=255, blank=True)
    public = models.BooleanField(default=True)
    active = models.BooleanField(default=True)
    isos = models.BooleanField("ISOs", default=True)
    rsync_user = models.CharField(max_length=50, blank=True, default='')
    rsync_password = models.CharField(max_length=50, blank=True, default='')
    notes = models.TextField(blank=True)

    class Meta:
        ordering = ('country', 'name')

    def __unicode__(self):
        return self.name

    def supported_protocols(self):
        protocols = MirrorProtocol.objects.filter(
            urls__mirror=self).order_by('protocol').distinct()
        return sorted(protocols)

    def downstream(self):
        return Mirror.objects.filter(upstream=self).order_by('name')

    def get_absolute_url(self):
        return '/mirrors/%s/' % self.name