コード例 #1
0
ファイル: options.py プロジェクト: PirosB3/django-mailer
class MessageOptions(GmailOptions):
    app_label = 'mailchecker'
    model_name = 'message'
    verbose_name = 'message'
    verbose_name_raw = 'message'
    verbose_name_plural = 'messages'
    object_name = 'message'
    default_related_name = None

    _gmail_pk_field = 'id'
    _gmail_fields = {
        'id': GmailAutoField(),
        'receiver': CharField(max_length=200),
        'sender': CharField(max_length=200),
        'snippet': CharField(max_length=200),
        'body': TextField(),
    }

    def _bind(self):
        super(MessageOptions, self)._bind()

        from .models import Thread, Message
        self.thread = ForeignKey(Thread)
        self.thread.contribute_to_class(Thread, 'thread')
        self.concrete_model = Message
        self._gmail_other_fields['thread'] = self.thread
コード例 #2
0
class MessageOptions(GmailOptions):
    app_label = 'mailchecker'
    model_name = 'message'
    verbose_name = 'message'
    verbose_name_raw = 'message'
    verbose_name_plural = 'messages'
    object_name = 'message'
    default_related_name = None

    _gmail_pk_field = 'id'
    _gmail_fields = {
        'id': GmailAutoField(),
        'receiver': CharField(max_length=200),
        'sender': CharField(max_length=200),
        'snippet': CharField(max_length=200),
        'body': TextField(),
    }

    def _bind(self):
        super(MessageOptions, self)._bind()

        from .models import Thread, Message
        self.thread = ForeignKey(Thread)
        self.thread.contribute_to_class(Thread, 'thread')
        self.concrete_model = Message
        self._gmail_other_fields['thread'] = self.thread
コード例 #3
0
 def contribute_to_class(self, cls, name):
     self.name = name
     self.fk_field_name = name + '_fk'
     self.ft_field_name = name + '_ft'
     setattr(cls, name, self)
     fk_field = ForeignKey(self.foreign_model, blank=True, null=True)
     fk_field.contribute_to_class(cls, self.fk_field_name)
     ft_field = CharField(max_length=255, blank=True)
     ft_field.contribute_to_class(cls, self.ft_field_name)
コード例 #4
0
ファイル: fields.py プロジェクト: Charlisim/opal
 def contribute_to_class(self, cls, name):
     self.name = name
     self.fk_field_name = name + '_fk'
     self.ft_field_name = name + '_ft'
     setattr(cls, name, self)
     fk_kwargs = dict(blank=True, null=True)
     if self.related_name:
         fk_kwargs['related_name'] = self.related_name
     fk_field = ForeignKey(self.foreign_model, **fk_kwargs)
     fk_field.contribute_to_class(cls, self.fk_field_name)
     ft_field = CharField(max_length=255, blank=True, null=True, default='')
     ft_field.contribute_to_class(cls, self.ft_field_name)
コード例 #5
0
ファイル: fields.py プロジェクト: anukat2015/opal-1
 def contribute_to_class(self, cls, name):
     self.name = name
     self.fk_field_name = name + '_fk'
     self.ft_field_name = name + '_ft'
     setattr(cls, name, self)
     fk_kwargs = dict(blank=True, null=True)
     if self.related_name:
         fk_kwargs['related_name'] = self.related_name
     fk_field = ForeignKey(self.foreign_model, **fk_kwargs)
     fk_field.contribute_to_class(cls, self.fk_field_name)
     ft_field = CharField(max_length=255, blank=True, null=True, default='')
     ft_field.contribute_to_class(cls, self.ft_field_name)
コード例 #6
0
ファイル: options.py プロジェクト: elbaschid/aws-meta-duck
class InstanceOptions(AwsOptions):
    auto_created = False
    app_label = 'aws_duck'
    model_name = 'instance'
    verbose_name = 'EC2 instance'
    verbose_name_raw = 'EC2 instance'
    verbose_name_plural = 'EC2 instances'
    object_name = 'instance'
    default_related_name = None

    _aws_pk_field = 'id'
    _aws_fields = {
        'id': AwsAutoField(),
        'ami_launch_index': CharField(max_length=200, editable=False),
        'architecture': CharField(max_length=200, editable=False),
        'block_device_mappings': CharField(max_length=200, editable=False),
        'client_token': CharField(max_length=200, editable=False),
        'ebs_optimized': CharField(max_length=200, editable=False),
        'hypervisor': CharField(max_length=200, editable=False),
        'iam_instance_profile': CharField(max_length=200, editable=False),
        'image_id': CharField(max_length=200, editable=False),
        'instance_id': CharField(max_length=200, editable=False),
        'instance_lifecycle': CharField(max_length=200, editable=False),
        'instance_type': CharField(max_length=200, editable=False),
        'kernel_id': CharField(max_length=200, editable=False),
        'key_name': CharField(max_length=200, editable=False),
        'launch_time': CharField(max_length=200, editable=False),
        'monitoring': CharField(max_length=200, editable=False),
        'network_interfaces': CharField(max_length=200, editable=False),
        'placement': CharField(max_length=200, editable=False),
        'platform': CharField(max_length=200, editable=False),
        'private_dns_name': CharField(max_length=200, editable=False),
        'private_ip_address': CharField(max_length=200, editable=False),
        'product_codes': CharField(max_length=200, editable=False),
        'public_dns_name': CharField(verbose_name='public DNS name',
                                     max_length=200,
                                     editable=False),
        'public_ip_address': CharField(verbose_name='public IP address',
                                       max_length=200, editable=False),
        'ramdisk_id': CharField(max_length=200, editable=False),
        'root_device_name': CharField(max_length=200, editable=False),
        'root_device_type': CharField(max_length=200, editable=False),
        'security_groups': CharField(max_length=200, editable=False),
        'source_dest_check': CharField(max_length=200, editable=False),
        'spot_instance_request_id': CharField(max_length=200, editable=False),
        'sriov_net_support': CharField(max_length=200, editable=False),
        'state': CharField(max_length=200, editable=False),
        'state_reason': CharField(max_length=200, editable=False),
        'state_transition_reason': CharField(max_length=200, editable=False),
        'subnet_id': CharField(max_length=200, editable=False),
        'tags': CharField(max_length=200, editable=False),
        'virtualization_type': CharField(max_length=200, editable=False),
        'vpc_id': CharField(max_length=200, editable=False),
    }

    def _bind(self):
        super()._bind()

        from .models import Image, Instance
        self.thread = ForeignKey(Image)
        self.thread.contribute_to_class(Image, 'ami')
        self.concrete_model = Instance
        self._aws_other_fields['thread'] = self.thread