示例#1
0
 def __init__(self,
              translated_field,
              language,
              to,
              to_field=None,
              *args,
              **kwargs):
     self._related_pre_init(translated_field, language, *args, **kwargs)
     OneToOneField.__init__(self, to, to_field, **kwargs)
     self._related_post_init()
示例#2
0
文件: models.py 项目: Maxzkp/TT
class Atractivo(models.Model):
    tipo = OneToOneField(Tipo, on_delete=CASCADE, blank=False)
    zona = OneToOneField(Zona, on_delete=CASCADE, blank=False)
    categorias = ManyToManyField(Categoria, blank=False)
    servicios = ManyToManyField(Servicio, blank=False)
    nombre = CharField(max_length=100, null=False, blank=False)
    direccion = CharField(max_length=100, null=False, blank=False)
    descripcion = CharField(max_length=600, null=False, blank=False)

    def __str__(self):
        return self.nombre
示例#3
0
class Invoce(BaseModel):
    target = OneToOneField(Target,on_delete=models.CASCADE,verbose_name = 'target',null=True,blank=False)
    server = OneToOneField(Server,on_delete=models.CASCADE,verbose_name="server",null=True,blank=False)

    class Meta:
        """Meta definition for Product."""
        verbose_name = 'Invoce'
        verbose_name_plural = 'Invoces'

    def __str__(self):
        """Unicode representation of Product."""
        return str(self.id)
示例#4
0
class Lesson(Model):
    lesson_number = IntegerField()
    video = CharField(null=True, default="", blank=True, max_length=200)
    text = TextField()
    title = CharField(max_length=50)
    quiz = OneToOneField(Quiz)
    badge = OneToOneField(Badge, default=None, blank=True, null=True)
    description = TextField()

    def __str__(self):
        return str(self.lesson_number) + ". " + self.title

    def __unicode__(self):
        return str(self.lesson_number) + ". " + self.title
示例#5
0
class Habitation(Model):
    title = CharField(max_length=20)
    rooms_nb = IntegerField()
    area = IntegerField()
    id_address = OneToOneField(
        Address, on_delete=CASCADE, blank=True,
        null=True)  # Shop-django / Django-address package
    description = TextField()
    compatibility_score = FloatField()
    is_furnished = BooleanField()
    price = IntegerField()
    id_user_poster = ForeignKey(
        CroomiesUser, on_delete=CASCADE, blank=True, null=True
    )  #il s'agit du gars qui met l'annonce #! remove blank=true et null=true
    id_time_slots = ForeignKey(Time_slots,
                               on_delete=CASCADE,
                               blank=True,
                               null=True)
    id_date_slots = ForeignKey(Date_slots,
                               on_delete=CASCADE,
                               blank=True,
                               null=True)

    def __str__(self):
        return "%s %s" % (self.title, self.description)
示例#6
0
class Customer(models.Model):
    user = OneToOneField(User, on_delete=models.CASCADE, null=True, blank=True)
    name = models.CharField(max_length=200, null=True)
    email = models.EmailField(max_length=200, null=True)

    def __str__(self):
        return f'Customer {self.id}, {self.name}, {self.email}'
示例#7
0
class Hypervisors(models.Model):
    id = models.IntegerField(primary_key=True)
    vendor = models.CharField(max_length=100)
    model = models.CharField(max_length=100)
    arch = models.CharField(max_length=100)
    cores = models.IntegerField()
    cells = models.IntegerField()
    threads = models.IntegerField()
    sockets = models.IntegerField()
    host_ip = models.CharField(max_length=100)
    hypervisor_hostname = models.CharField(max_length=100)
    hypervisor_type = models.CharField(max_length=100)
    hypervisor_version = models.CharField(max_length=100)
    local_gb = models.IntegerField()
    local_gb_used = models.IntegerField()
    memory_mb = models.IntegerField()
    memory_mb_used = models.IntegerField()
    running_vms = models.IntegerField()
    service = OneToOneField('Services',
                            on_delete=models.CASCADE,
                            related_name='hypervisor',
                            null=True)
    state = models.CharField(max_length=10)
    status = models.CharField(max_length=10)
    vcpus = models.IntegerField()
    vcpus_used = models.IntegerField()
示例#8
0
class Partner(User):
     ###--------------------------------- Company Info ---------------------###
    user = OneToOneField(User, on_delete=models.CASCADE,primary_key=True)
    
    partner_phone = models.CharField(max_length = 12,blank = True, null =True)
    partner_address1 = models.CharField(max_length = 300, blank = True,null = True)
    partner_address2 = models.CharField(max_length = 300, blank = True,null = True)
    partner_state  = models.CharField(max_length =2,choices=STATE_CHOICES,verbose_name="state",blank = True, null =True)
    partner_zip = models.CharField(max_length = 5 , blank = True, null =True)
    partner_name = models.CharField(max_length = 300, blank = True,null = True)
   
    partner_mission = models.CharField(max_length = 300, blank = True,null = True)
    partner_logo = models.ImageField(upload_to ='partnerLogos',blank  = True,null = True,default="avatars/default.png")
    
     ###--------------------------------- Misc. INfo for web app ---------------------###
    partner_web_address = models.CharField(max_length = 255,blank = True, null = True)
    partner_isPart = models.FloatField(default = True);
    partner_Lat = models.FloatField(blank = True, null =True,default=0.0)
    partner_Lon = models.FloatField(blank = True, null =True,default=0.0)
    partner_point = models.PointField(null=True, blank=True,default ="0101000020E6100000EC884336906740407B911A248E495DC0" )
    
    
    class Meta:
        
        db_table = 'partner'  
    def __str__(self):
        return str(self.user)
示例#9
0
class Review(models.Model):
    '''
    实验审核表。

    Attributes:
        experiment: 审核的实验。
        is_passed: 是否通过。
        reply: 回复。
        user: 审核人。
        created_time: 创建时间。
    '''

    experiment = OneToOneField(Experiment,
                               null=False,
                               on_delete=models.CASCADE)
    is_passed = models.BooleanField(null=True)
    reply = models.CharField(max_length=128)
    user = models.ForeignKey(User,
                             null=True,
                             on_delete=models.SET_NULL,
                             related_name='%(class)s')
    created_time = models.DateTimeField(auto_now_add=True)

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

    class Meta:
        db_table = "experiment_review"
        ordering = ["-created_time"]
        verbose_name = "Review"
        verbose_name_plural = "Reviews"
示例#10
0
    class SQLiteFTSIndexEntry(models.Model):
        autocomplete = TextField(null=True)
        title = TextField(null=False)
        body = TextField(null=True)
        index_entry = OneToOneField(primary_key=True, to='wagtailsearch.indexentry', on_delete=models.CASCADE, db_column='rowid')

        class Meta:
            db_table = "wagtailsearch_indexentry_fts"
示例#11
0
class Profile(models.Model):
    user = OneToOneField(User, on_delete=CASCADE)
    profile_img = models.URLField(max_length=100, default="https://picsum.photos/200")
    cur_city = models.CharField(max_length=100)
   

    def __str__(self):
        return f"{self.user.username} is currently living in {self.cur_city}"
示例#12
0
class UserInfo(models.Model):
    """
    Other user information.
    """
    user = OneToOneField(User, primary_key=True)
    registration_token = TextField(null=True, blank=True)
    organization = TextField()
    full_name = TextField()
    edx_instance = ForeignKey(BackingInstance, blank=True, null=True)
示例#13
0
class MetaLink(Model):
    """
    The link to the company.

    This is the root of the companies required meta data.
    The types related to this model will provide which meta data is
    required for a certain company.
    """

    company = OneToOneField(Company, CASCADE, related_name="metadata")
示例#14
0
class Employee(models.Model):
    user = OneToOneField(User,
                         on_delete=models.CASCADE,
                         related_name='employee')
    name = CharField(max_length=64)
    surname = CharField(max_length=64)
    post = CharField(max_length=128)
    experience = CharField(max_length=128)

    def __str__(self) -> str:
        return f'{self.name} {self.surname}'
示例#15
0
class DevSkillSet(models.Model):
    dev = OneToOneField(Dev, on_delete=models.CASCADE)
    skill_sets = models.ManyToManyField(SkillSet)

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

    class Meta:
        ordering = (
            "-id",
        )
示例#16
0
class Profile(models.Model):
    GENDER = (
        ('F', 'Female'),
        ('M', 'Male')
    )

    user = OneToOneField(User)
    gender = models.CharField(max_length=20, null=True, blank=True, choices=GENDER)
    avatar = models.ImageField(upload_to='avatars', blank=True)
    birth_date = models.DateField(null=True, blank=True)
    about_me = models.TextField(null=True, blank=True)
    registration_date = models.DateField(auto_now_add=True)
示例#17
0
class UserProfile(Model):
    user = OneToOneField(User)
    lessons = ManyToManyField(Lesson, null=True, default=None, blank=True)
    badges = ManyToManyField(Badge, null=True, default=None, blank=True)
    goals = ManyToManyField(Goal, null=True, default=None, blank=True)
    posts = ManyToManyField(Post, null=True, default=None, blank=True)

    def __str__(self):
        return self.user.email + " profile"

    def __unicode__(self):
        return self.user.email + " profile"
示例#18
0
class ExchangeRecord(models.Model):
    tranlist = OneToOneField(ScoreTranlist, primary_key=True)
    commodity = models.ForeignKey(Commodity, related_name="exchange_record")
    name = models.CharField(u'收件人姓名', max_length=20)
    tel = models.CharField(u'收件人手机号', max_length=14)
    addr = models.CharField(u'收件人地址', max_length=100)
    message = models.CharField(u'留言', default=u"暂无", max_length=100)
    user_event = GenericRelation("UserEvent",related_query_name='exchangerecord')
    def __unicode__(self):
        return u"%s:收件人为 %s" % (self.tranlist.user, self.name)
    class Meta:
        ordering = ["-tranlist__time",]
示例#19
0
class Device(Model, metaclass=DeviceMeta):
    """
    Abstract Device Model.

    This model defines a multi factor option for a user.
    If a user doesn't have a device of a certain type of
    verification, then the type isn't available for the user.
    """
    class Meta:  # noqa: D106
        abstract = True
        ordering = ("id", )

    user = OneToOneField(User, on_delete=CASCADE)
示例#20
0
class Encuesta(models.Model):
    users = OneToOneField(CustomUsuarios, on_delete=models.CASCADE)
    pub_date = models.DateTimeField('Se realizó el: ', auto_now_add=True)
    option = models.CharField(max_length=200)
    asignatura = models.CharField(max_length=200)
    value1 = [
        ('0', '0'),
        ('1', '1'),
        ('2', '2'),
        ('3', '3'),
        ('4', '4'),
        ('5', '5'),
    ]
    values = models.CharField(max_length=20, default='5', choices=value1)
示例#21
0
class GiaoVien(models.Model):
    user = OneToOneField(User)
    
    ma_so=PositiveIntegerField(blank=False, null=False,
                               unique=True,
                               verbose_name="Mã số")
    
    ho_ten = CharField(blank=False, null=False,
                       max_length=50,
                       verbose_name="Họ và tên")
    
    don_vi = ForeignKey(DonVi, verbose_name='Đơn vị', help_text="Đơn vị quản lý trực tiếp")
    
#     lop = ForeignKey(Lop, blank=False, null=False,
#                      verbose_name="Lớp")
    # tam the da, co the can them cac truong khac
    

    class Meta:
        verbose_name = "Giáo viên"
        verbose_name_plural = "Danh sách giáo viên"

    def __unicode__(self):
        return u'%s (%s)' %(self.ho_ten, self.don_vi)
    
    def save(self, *args, **kwargs):
        '''
        when save a student, we also make a user who can login to make exam
        '''
        u = 'GV'+str(self.ma_so)
        # check if this GV already exist in user table
        users = User.objects.filter(username=u)
        # if not
        if len(users) == 0:
            # then create a new user 
            new_user = User.objects.create_user(username=u, password=self.ma_so)
            new_user.is_staff = True
            new_user.save()
            self.user = new_user
        else:
            self.user = users[0];
        super(GiaoVien, self).save(*args, **kwargs)
        
    def delete(self, using=None):
        '''
        also delete from user table
        '''
        user = User.objects.get_by_natural_key(self.ma_so)
        User.delete(user, using)
        models.Model.delete(self, using=using)
示例#22
0
文件: models.py 项目: ibaiC/PawPals
class Shelter(models.Model):

    # relationship fields
    manager = OneToOneField(User, blank=True, on_delete=models.CASCADE)

    # fields
    name = models.CharField(max_length=128,
                            primary_key=True)  # name and surname
    bio = models.CharField(max_length=extended_char_len)
    webpage = models.URLField(blank="True")
    phone_contact = models.CharField(max_length=phone_len, unique=True)
    availability_info = models.CharField(max_length=extended_char_len)
    location = models.CharField(max_length=standard_char_len)
    avg_difficulty_rating = models.IntegerField(
        default=5, validators=difficulty_validators)

    slug = models.SlugField(unique=True)

    def shelter_image_path(self, filename):
        return (os.path.join("shelters_profile_images", filename))

    profile_picture = models.ImageField(upload_to=shelter_image_path,
                                        blank="True")

    def save(self, *args, **kwargs):

        # set slug
        self.slug = slugify(self.name)

        # set average difficulty rating
        sum = 0
        count = 0

        shelter_dogs = Dog.objects.all().filter(dog_shelter=self)

        for dog in shelter_dogs:
            reviews = Review.objects.all().filter(reviewed_dog=dog)
            sum += np.sum([review.difficulty_rating for review in reviews])
            count += len(reviews)

        if (count):
            self.avg_difficulty_rating = int(sum / count)
        else:
            self.avg_difficulty_rating = 0

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

    def __str__(self):
        return self.name
示例#23
0
class TipoMov(models.Model):
    name = CharField(max_length=100)
    pos = PositiveSmallIntegerField()
    is_active = BooleanField(default=True)
    created_at = DateTimeField(auto_now_add=True)
    updated_at = DateTimeField(auto_now=True)
    folio = OneToOneField(Folio,
                          related_name="tipo_mov",
                          null=True,
                          on_delete=models.PROTECT)

    def __str__(self):
        return f"TipoMov {self.name}, actualmente activa: {self.is_active}"

    objects = MantenedorManager()
示例#24
0
class Challenge(Model, ChallengeMixin):
    """
    Abstract Challenge model.

    Subclasses of the Abstract Device model MUST create
    a Challenge for it. Subclasses of this model will act
    as the relation between a device and a auth token.
    """
    class Meta:  # noqa: D106
        abstract = True
        unique_together = ("token", "device")

    token = OneToOneField(Token, on_delete=CASCADE)

    confirm = BooleanField(default=False)
示例#25
0
class ColourTheme(Model):
    """The storage for the colouring theme stored for a company."""

    company = OneToOneField(Company, CASCADE, related_name="theme")

    primary = BigIntegerField(validators=[
        MinValueValidator(0x000000),
        MaxValueValidator(0xFFFFFFFF)
    ])

    accent = BigIntegerField(validators=[
        MinValueValidator(0x000000),
        MaxValueValidator(0xFFFFFFFF)
    ])

    logo = ForeignKey(Image, SET_NULL, null=True)
class Profile(models.Model):
    user = OneToOneField(User, on_delete=models.CASCADE)
    bio = models.TextField(default='bio of user')
    profile_pic = models.ImageField(null=True,
                                    blank=True,
                                    upload_to="profile/")
    website_url = models.CharField(max_length=255, null=True, blank=True)
    fb_url = models.CharField(max_length=255, null=True, blank=True)
    twitter_url = models.CharField(max_length=255, null=True, blank=True)
    instagram_url = models.CharField(max_length=255, null=True, blank=True)
    pinterest_url = models.CharField(max_length=255, null=True, blank=True)

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

    def get_absolute_url(self):
        return reverse('home')
示例#27
0
class Vehicle(models.Model):
    driver = OneToOneField(Driver,
                           on_delete=models.CASCADE,
                           verbose_name='motorizado')
    serial_number = models.CharField(max_length=10,
                                     verbose_name='número de serie de la moto')
    license_code = models.CharField(max_length=10,
                                    verbose_name='código de brevete')
    license_plate_number = models.CharField(max_length=10,
                                            verbose_name='número de placa')

    def __str__(self):
        return self.serial_number

    class Meta:
        verbose_name = "vehiculo"
        verbose_name_plural = "vehiculos"
示例#28
0
class Veteran(User):
    VET_BRANCH_CHOICES = (
    ('','---------'),
    ('usaf','Air Force'),
    ('usa', 'Army'),
    ('uscg', 'Coast Guard'),
    ('usmc', 'Marines'),
    ('usn', 'Navy'),

    
    )
    VET_BOOL_CHOICES = (
    ('','---------'),
    (True,'Yes'),
    (False, 'No'),

    
    )

    user = OneToOneField(User, on_delete=models.CASCADE,primary_key=True)
   
    ###--------------------------------- Personal Info ---------------------###
   
    vet_mobile = models.CharField(max_length = 12,blank = True, null =True)
    vet_state  = models.CharField(max_length =2,choices=STATE_CHOICES,verbose_name="state",blank = True, null =True)
    vet_zip = models.CharField(max_length = 5 , blank = True, null =True)
    ###--------------------------------- Combat Info ---------------------###
    vet_branch = models.CharField(max_length = 4,choices=VET_BRANCH_CHOICES,verbose_name="vet_branch")
    vet_unit = models.CharField(max_length = 50,blank = True, null =True)
    vet_isPost911 = models.BooleanField(blank = True, null =True,choices=VET_BOOL_CHOICES,verbose_name="vet_isPost911")
    vet_isCombat = models.BooleanField(blank = True, null =True,choices=VET_BOOL_CHOICES,verbose_name="vet_isCombat")
    
    ###--------------------------------- Misc. INfo for web app ---------------------###
    vet_isVet = models.BooleanField(default = True)
    vet_isNotifications =  models.BooleanField(blank = True, null =True,choices=VET_BOOL_CHOICES,verbose_name="vet_isNotifications")
    vet_isShared =  models.BooleanField(blank = True, null =True,choices=VET_BOOL_CHOICES,verbose_name="vet_isShared")
    vet_isSignedUp  =  models.BooleanField(blank = True, null =True,choices=VET_BOOL_CHOICES,verbose_name="vet_isSignedUp")
    vet_Lat = models.FloatField(blank = True, null =True,default=0.0)
    vet_Lon = models.FloatField(blank = True, null =True,default=0.0)
    vet_point = models.PointField(null=True, blank=True,default ="0101000020E6100000EC884336906740407B911A248E495DC0" )
    class Meta:
        
        db_table = 'veteran'  
    def __str__(self):
        return str(self.user)
示例#29
0
class Encuesta(models.Model):
    users       = OneToOneField(CustomUsuarios, on_delete=models.CASCADE)
    pub_date    = models.DateTimeField('Se realizó el: ', auto_now_add=True)
    option      = models.CharField(max_length=200)
    asignatura  = models.CharField(max_length=200)
    value1      = [  ('0', '0'), ('1','1'), 
                     ('2', '2'), ('3','3'), 
                     ('4', '4'), ('5','5'),  ]
    values        = models.CharField(max_length=20, default= '5', choices=value1)          






#2976
# django.db.utils.ProgrammingError: no existe la relación «Egresados_encuesta»
# LINE 1: INSERT INTO
示例#30
0
class Profile(QuicksellModel):
	"""User profile info."""

	user = OneToOneField(
		User, related_name='_profile', primary_key=True,
		editable=False, on_delete=CASCADE
	)
	uuid = UUIDField(default=uuid.uuid4, unique=True, editable=False)
	date_created = DateField(default=date.today, editable=False)
	full_name = CharField(max_length=100, blank=True)
	about = TextField(blank=True)
	online = BooleanField(default=True)
	rating = IntegerField(default=0)
	avatar = ImageField(null=True, blank=True, upload_to='images/avatars')
	location = ForeignKey(**location_fk_kwargs)

	def __str__(self):
		return str(self.user) + "'s profile."
示例#31
0
                    raise FieldError('Local field %r in class %r clashes '
                                     'with field of similar name from '
                                     'base class %r' %
                                        (field.name, name, base.__name__))

            # 更多关于 meta.abstract 请参见: https://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes
            if not base._meta.abstract:
                # Concrete classes...
                base = base._meta.concrete_model

                if base in o2o_map:
                    field = o2o_map[base]

                elif not is_proxy:
                    attr_name = '%s_ptr' % base._meta.module_name
                    field = OneToOneField(base, name=attr_name,
                            auto_created=True, parent_link=True)
                    new_class.add_to_class(attr_name, field)
                else:
                    field = None
                new_class._meta.parents[base] = field
            else:
                # .. and abstract ones.
                for field in parent_fields:
                    new_class.add_to_class(field.name, copy.deepcopy(field))

                # Pass any non-abstract parent classes onto child.
                new_class._meta.parents.update(base._meta.parents)

            # Inherit managers from the abstract base classes.
            new_class.copy_managers(base._meta.abstract_managers)
 def __init__(self, translated_field, language, to, to_field=None, *args,
              **kwargs):
     self._related_pre_init(translated_field, language, *args, **kwargs)
     OneToOneField.__init__(self, to, to_field, **kwargs)
     self._related_post_init()