Exemplo n.º 1
0
class Module(Element):
    app_label = models.CharField(_('application label'),
                                 max_length=64,
                                 unique=True)
    name = models.CharField(_('name'), max_length=128, null=False, unique=True)
    description = models.CharField(_('description'), max_length=256)
    author = models.CharField(_('author'), max_length=64)
    license_type = models.CharField(
        _('license'),
        max_length=64,
        help_text='Commercial, BSD, MIT, LGPL, GPL...')
    version = models.CharField(max_length=32, verbose_name=_('version'))
    db_version = models.PositiveIntegerField(_('DB version'),
                                             help_text=_('Database version'),
                                             null=True)
    last_update = models.PositiveIntegerField(_('last update'))
    icon = models.CharField(_('icon'), max_length=256)
    details = models.TextField(_('details'))
    dependencies = models.TextField(_('dependencies'))
    tooltip = models.CharField(_('tooltip'), max_length=64)
    visible = models.BooleanField(_('visible'), default=True)

    class Meta:
        verbose_name = _('module')

    def __str__(self):
        return '%s (%s)' % (self.app_label, self.name)
Exemplo n.º 2
0
class Attribute(models.Model):
    ATT_TYPE = (
        ('text', _('Text')),
        ('date', _('Date')),
        ('time', _('Time')),
        ('datetime', _('Date/Time')),
        ('money', _('Money')),
        ('integer', _('Integer')),
        ('float', _('Float')),
        ('textarea', _('Text Area')),
        ('choice', _('Choice')),
        ('multiplechoice', _('Multiple Choices')),
        ('foreignkey', _('Foreign Key')),
        ('logical', _('Logical')),
        ('image', _('Image')),
        ('file', _('File')),
    )
    content_type = models.ForeignKey(ContentType)
    name = models.CharField(_('attribute name'), max_length=64)
    att_type = models.CharField(_('attribute type'),
                                max_length=16,
                                choices=ATT_TYPE)
    widget_attrs = models.TextField(_('widget attributes'))
    default_value = models.TextField(_('default value'),
                                     help_text=_('Default attribute value'))
    trigger = models.TextField(_('attribute trigger'),
                               help_text=_('Trigger attribute code'))

    class Meta:
        db_table = 'base_attribute'
Exemplo n.º 3
0
class Translation(models.Model):
    """
    Translates database field value.
    """
    content_type = models.ForeignKey(ContentType)
    name = models.CharField(_('name'), max_length=64)
    language = models.ForeignKey(Language, verbose_name=_('language'))
    source = models.TextField(_('source'), db_index=True)
    value = models.TextField(_('value'))

    class Meta:
        unique_together = (('content_type', 'name'))
        verbose_name = _('translation')
        verbose_name_plural = _('translations')
Exemplo n.º 4
0
class Comment(models.Model):
    """
    Provides user comment to any allowed content object.
    """
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             verbose_name=_('user'),
                             null=False)
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    comment = models.TextField(_('comment'))
    submit_date = models.DateTimeField(_('date/time submitted'),
                                       default=datetime.datetime.now())
    ip_address = models.GenericIPAddressField(_('IP address'),
                                              unpack_ipv4=True)
    is_public = models.BooleanField(_('is public'), default=True,
                    help_text=_('Uncheck this box to make the comment effectively ' \
                                'disappear from the site.'))
    is_removed = models.BooleanField(_('is removed'), default=False,
                    help_text=_('Check this box if the comment is inappropriate. ' \
                                'A "This comment has been removed" message will ' \
                                'be displayed instead.'))

    class Meta:
        db_table = 'comment_content'
Exemplo n.º 5
0
class Group(models.Model):
    PRIVACY = (
        ('public', _('Public')),
        ('private', _('Private')),
    )
    owner = models.ForeignKey(settings.AUTH_USER_MODEL,
                              verbose_name=_('owner'),
                              null=False)
    create_date = models.DateTimeField(auto_now_add=True, null=False)
    name = models.CharField(_('name'),
                            max_length=100,
                            null=False,
                            unique=True,
                            help_text=_('Group name'))
    description = models.TextField(_('description'))
    email = models.EmailField()
    privacy = models.CharField(max_length=16,
                               choices=PRIVACY,
                               default='public',
                               null=False)

    # TODO: add image field here

    class Meta:
        db_table = 'comment_group'
Exemplo n.º 6
0
class Action(ModuleElement):
    action_types = {}
    name = models.CharField(_('name'), max_length=128, null=False, unique=True)
    short_description = models.CharField(_('short description'), max_length=32)
    description = models.CharField(max_length=256,
                                   verbose_name=_('description'))
    action_type = models.CharField(_('type'), max_length=32, null=False)
    context = models.TextField(_('context'))

    class Meta:
        verbose_name = _('actions')

    def get_action_type(self):
        return None

    def get_context(self):
        if self.context:
            return json.dumps(self.context)
        else:
            return {}

    def save(self, *args, **kwargs):
        self.action_type = self.get_action_type()
        super(Action, self).save(*args, **kwargs)

    def execute(self, request, *args, **kwargs):
        return self.action_types[self.action_type].objects.get(
            pk=self.pk).execute(request, *args, **kwargs)
Exemplo n.º 7
0
class Contact(base.CompanyModel):
    name = models.CharField(_('name'), max_length=128, null=False)
    #image
    active = models.BooleanField(_('active'), default=True)
    parent_id = models.ForeignKey('self')
    partner_category = models.ForeignKey(Category,
                                         verbose_name=_('partner category'))
    language = models.ForeignKey('base.Language')
    time_zone = models.CharField(_('time zone'), max_length=32)
    comment = models.TextField(_('comments'))
    is_customer = models.BooleanField(_('is customer'), default=False)
    is_supplier = models.BooleanField(_('is supplier'), default=False)
    is_employee = models.BooleanField(_('is employee'), default=False)
    is_company = models.BooleanField(_('is company'), default=False)
    address = models.CharField(_('address'), max_length=256)
    country = models.ForeignKey('base.Country', verbose_name=_('country'))
    email = models.EmailField('e-mail')
    website = models.URLField('website')
    phone = models.CharField(_('phone'), max_length=64)
    phone = models.CharField(_('fax'), max_length=64)
    mobile = models.CharField(_('mobile'), max_length=64)
    birthdate = models.DateField(_('birthdate'))
    use_company_address = models.BooleanField(_('use company address'),
                                              default=False)

    class Meta:
        db_table = 'contact'
Exemplo n.º 8
0
class Company(Element):
    """
    Company configuration model.
    """
    name = models.CharField(_('name'),
                            max_length=128,
                            help_text=_('Company name'),
                            null=False)
    parent = models.ForeignKey('self')
    report_header = models.TextField(_('report header'))
    report_footer = models.TextField(_('report footer'))
    currency = models.ForeignKey('base.Currency', verbose_name=_('currency'))
    zip = models.CharField(_('zip'), max_length=24)
    country = models.ForeignKey('base.Country')
    #logo = models.ImageField(_('Logo'))
    email = models.EmailField('e-mail')
    phone = models.CharField(_('phone'), max_length=64)
    fax = models.CharField(_('fax'), max_length=64)
    website = models.URLField('website')
    comment = models.TextField(_('comments'), help_text=_('Company comments'))
Exemplo n.º 9
0
class AttributeValue(models.Model):
    attribute = models.ForeignKey(Attribute)
    object_id = models.PositiveIntegerField()
    text_value = models.CharField(max_length=1024)
    texta_value = models.TextField()
    logical_value = models.BooleanField()
    #file_value = models.FileField()
    fk_value = models.PositiveIntegerField()
    int_value = models.IntegerField()
    decimal_value = models.MoneyField()
    date_value = models.DateTimeField()

    class Meta:
        db_table = 'base_attribute_value'
Exemplo n.º 10
0
class Default(models.Model):
    model = models.ForeignKey(BaseModel,
                              verbose_name=_('model'),
                              on_delete='CASCADE')
    field = models.CharField(_('field'), max_length=64)
    value = models.TextField(_('value'))
    user = models.ForeignKey('base.User',
                             verbose_name=_('user'),
                             help_text=_('leave blank for all users'))

    class Meta:
        db_table = 'base_default'
        verbose_name = _('default field value')
        verbose_name_plural = _('default fields values')
Exemplo n.º 11
0
class Message(models.Model):
    """
    User message box.
    """
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             verbose_name=_('user'),
                             null=False)
    send_date = models.DateTimeField(_('date/time send'),
                                     default=datetime.datetime.now())
    message = models.TextField(_('comment'))
    read_date = models.DateTimeField(_('date/time read'))
    starred = models.BooleanField(_('starred'))
    job = models.BooleanField(_('job'))

    class Meta:
        db_table = 'comment_message'
Exemplo n.º 12
0
class Attachment(models.Model):
    name = models.CharField(max_length=128, null=False, verbose_name=_('name'))
    description = models.TextField(_('description'))
    type = models.CharField(_('type'),
                            max_length=16,
                            choices=(('url', 'URL'), ('file', _('File'))))
    body = models.BinaryField(_('body'))
    url = models.URLField('URL')
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')

    class Meta:
        db_table = 'base_attachment'
        verbose_name = _('attachment')
        verbose_name = _('attachments')
Exemplo n.º 13
0
class View(ModuleElement):
    FORMATS = (
        ('django', 'Django template'),
        ('mako', 'Mako template'),
        ('jinja', 'Jinja template'),
        ('xml', 'XML'),
        ('json', 'JSON'),
        ('yaml', 'YAML'),
    )
    name = models.CharField(_('name'), max_length=128, null=False, unique=True)
    description = models.CharField(_('description'), max_length=256)
    format = models.CharField(_('format'),
                              max_length=16,
                              choices=FORMATS,
                              default='django')
    model = models.ForeignKey(BaseModel, verbose_name=_('model'))
    definition = models.TextField(_('definition'))

    class Meta:
        verbose_name = _('view')
        verbose_name_plural = _('views')
Exemplo n.º 14
0
class UserLog(models.Model):
    """
    User log record.
    """
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             verbose_name=_('user'),
                             null=False,
                             related_name='+')
    content_type = models.ForeignKey(ContentType,
                                     verbose_name=_('content type'),
                                     null=False,
                                     related_name='+')
    object_id = models.PositiveIntegerField(_('object id'))
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    operation = models.CharField(
        max_length=64, null=False)  # create, read, update, delete, print...
    description = models.TextField()
    log_time = models.DateTimeField(_('date/time'),
                                    null=False,
                                    auto_now_add=True)

    class Meta:
        db_table = 'base_user_log'
Exemplo n.º 15
0
class User(auth.AbstractUser):
    email_signature = models.TextField(_('e-mail signature'))
    report_signature = models.TextField(_('report signature'))

    class Meta:
        db_table = 'auth_user'
Exemplo n.º 16
0
class Company(Partner):
    address = models.TextField()
    employee = models.ForeignKey(Person)

    class Meta:
        proxy = True