Esempio n. 1
0
class UserContent(models.Model):
    """
    User/author content object log.
    """
    content_type = models.ForeignKey(ContentType,
                                     verbose_name=_('content type'),
                                     null=False,
                                     related_name='+')
    object_id = models.PositiveIntegerField(_('object id'), null=False)
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    created_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                   verbose_name=_('created by'),
                                   null=False,
                                   related_name='+')
    created_on = models.DateTimeField(auto_now_add=True,
                                      verbose_name=_('created on'),
                                      null=False)
    modified_by = models.ForeignKey(settings.AUTH_USER_MODEL,
                                    verbose_name=_('modified by'),
                                    related_name='+')
    modified_on = models.DateTimeField(auto_now=True,
                                       verbose_name=_('modified on'))

    class Meta:
        db_table = 'base_user_content'
Esempio n. 2
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'
Esempio n. 3
0
class FormAction(Action):
    VIEW_TYPE = (
        ('form', 'Form'),
        ('list', 'List'),
        ('chart', 'Chart'),
        ('calendar', 'Calendar'),
        ('kanban', 'Kanban'),
    )
    VIEW_STATE = (
        ('read', _('Read')),
        ('write', _('Write')),
        ('create', _('Create')),
        ('delete', _('Delete')),
    )
    view = models.ForeignKey(View, verbose_name=_('view'))
    model = models.ForeignKey(BaseModel, verbose_name=_('model'))
    target = models.CharField(_('target'), max_length=32)
    view_type = models.CharField(_('initial view'),
                                 max_length=16,
                                 choices=VIEW_TYPE,
                                 default='list')
    view_types = models.CharField(_('view types'), max_length=64)
    state = models.CharField(_('state'), max_length=16)

    def get_action_type(self):
        return 'form'

    class Meta:
        db_table = 'base_form_action'
        verbose_name = _('form action')
        verbose_name_plural = _('form actions')

    def execute(self, request, *args, **kwargs):
        from .views import actions
        return actions.response_form(request, self)
Esempio n. 4
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'
Esempio n. 5
0
class CurrencyRate(models.Model):
    date = models.DateField(_('date'))
    currency = models.ForeignKey(base.Currency, verbose_name=_('currency'))
    currency_rate_type = models.ForeignKey(CurrencyRateType,
                                           verbose_name=_('rate type'))
    rate = models.MoneyField(_('rate'))

    class Meta:
        db_table = 'base_currency_rate'
Esempio n. 6
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')
Esempio n. 7
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')
Esempio n. 8
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'
Esempio n. 9
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'
Esempio n. 10
0
class Follow(models.Model):
    """
    Used to user follow any allowed content object.
    """
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             null=False,
                             related_name='+')
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    join_date = models.DateTimeField(_('date/time'),
                                     auto_now_add=True,
                                     null=False)
    active = models.BooleanField(default=True)

    class Meta:
        db_table = 'comment_follow'
Esempio n. 11
0
class Category(models.Model):
    name = models.CharField(_('name'),
                            max_length=64,
                            help_text=_('Category name'))
    active = models.BooleanField(_('active'), default=True)
    parent = models.ForeignKey('self', verbose_name=_('parent category'))

    class Meta:
        db_table = 'contact_category'
Esempio n. 12
0
class ModelData(models.Model):
    name = models.CharField(max_length=128, db_index=True)
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey('content_type', 'object_id')
    can_change = models.BooleanField(default=True)

    class Meta:
        db_table = 'base_model_data'
Esempio n. 13
0
class State(models.Model):
    country = models.ForeignKey(Country, verbose_name=_('country'), null=False)
    code = models.CharField(_('code'), max_length=3, null=False)
    name = models.CharField(_('name'), max_length=64, null=False)

    class Meta:
        db_table = 'base_state'
        unique_together = (('country', 'code'), ('country', 'name'))
        verbose_name = _('state')
Esempio n. 14
0
class Country(models.Model):
    name = models.CharField(_('name'), max_length=64, unique=True)
    code = models.CharField(_('country code'),
                            max_length=2,
                            help_text='The ISO country code')
    language = models.ForeignKey(Language, verbose_name=_('language'))
    phone_code = models.CharField(_('phone code'), max_length=10)

    class Meta:
        verbose_name = _('country')
Esempio n. 15
0
class ViewAction(Action):
    view = models.ForeignKey(View, verbose_name=_('view'))

    class Meta:
        db_table = 'base_view_action'
        verbose_name = _('view action')
        verbose_name_plural = _('view actions')

    def get_action_type(self):
        return 'view'
Esempio n. 16
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'))
Esempio n. 17
0
class ReportAction(Action):
    report = models.ForeignKey(Report, verbose_name=_('report'))

    class Meta:
        db_table = 'base_report_action'
        verbose_name = _('report action')
        verbose_name_plural = _('report actions')

    def get_action_type(self):
        return 'report'

    def execute(self, request, *args, **kwargs):
        pass
Esempio n. 18
0
class Field(Element):
    model = models.ForeignKey(BaseModel, verbose_name=_('model'), null=False)
    name = models.CharField(max_length=64,
                            null=False,
                            unique=True,
                            verbose_name=_('name'))
    description = models.CharField(_('description'), max_length=64)
    help_text = models.CharField(_('help text'), max_length=128)

    class Meta:
        db_table = 'base_field'
        verbose_name = _('field')
        verbose_name_plural = _('fields')
Esempio n. 19
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'
Esempio n. 20
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'
Esempio n. 21
0
class Bank(models.Model):
    code = models.CharField(_('Bank Identifier Code'), max_length=64)
    name = models.CharField(_('name'),
                            max_length=128,
                            help_text=_('Bank name'))
    active = models.BooleanField(_('active'), default=True)
    country = models.ForeignKey('base.Country', verbose_name=_('country'))
    email = models.EmailField('e-mail')

    class Meta:
        db_table = 'base_bank'

    class Extra:
        display_expression = ('code', 'name')
Esempio n. 22
0
class BaseModel(ModuleElement):
    content_type = models.OneToOneField(ContentType)
    ancestor = models.ForeignKey('self', verbose_name=_('base model'))
    #name = models.CharField(max_length=64, verbose_name=_('Class Name'), null=False, unique=True)
    #db_table = models.CharField(max_length=64, verbose_name=_('Table Name'), null=False, db_index=True)
    description = models.CharField(_('description'), max_length=128)
    is_abstract = models.BooleanField(_('is abstract'), default=False)

    objects = BaseModelManager()

    class Meta:
        db_table = 'base_model'
        verbose_name = _('model')

    def __str__(self):
        return '%s.%s' % (self.content_type.app_label, self.content_type.model)
Esempio n. 23
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'
Esempio n. 24
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')
Esempio n. 25
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')
Esempio n. 26
0
class Menu(ModuleElement):
    name = models.CharField(_('name'),
                            max_length=128,
                            null=False,
                            db_index=True)
    parent = models.ForeignKey('self', verbose_name=_('parent'))
    action = models.ForeignKey(Action, verbose_name=_('action'))
    image = models.CharField(_('image'),
                             max_length=256,
                             help_text=_('menu image file path'))
    sequence = models.PositiveIntegerField(_('sequence'),
                                           help_text=_('menu item sequence'),
                                           default=0,
                                           db_index=True)

    objects = MenuManager()

    class Meta:
        db_table = 'base_menu'
        verbose_name = _('menu item')
        verbose_name_plural = _('menu items')
        ordering = ['sequence', 'id']

    def __str__(self):
        return self.get_full_name()

    @property
    def is_leaf(self):
        return self.__class__.objects.filter(parent_id=self.pk).count() == 0

    def get_full_name(self):
        parents = []
        parent = self
        while parent:
            parents.insert(0, parent.name)
            parent = parent.parent
        return '/'.join(parents)

    def set_full_name(self, path):
        cls = self.__class__
        menu = None
        parents = path.split('/')
        self.name = parents[-1]
        for item in parents[:-1]:
            parent = menu
            try:
                menu = cls.objects.get(parent_id=menu, name=item)
            except:
                menu = None
            if not menu:
                menu = cls.objects.create(name=item.replace('\\', '/'),
                                          parent=parent,
                                          module_id=self.module_id)
        self.parent = menu

    full_name = property(get_full_name, set_full_name)

    ## Auto create model form action for target menu item
    def get_model(self):
        if self.action and self.action.action_type == 'form':
            return FormAction.objects.get(pk=self.action.pk).model

    def set_model(self, model):
        if isinstance(model, str):
            model = model.split('.')
            model = BaseModel.objects.get(content_type__app_label=model[0],
                                          content_type__model=model[1])
        action = FormAction.objects.create(
            name='%s "%s.%s"' %
            (('showmodel', ) + model.content_type.natural_key()),
            model=model)
        self.action = action
        self.image = '/static/keops/icons/page.png'

    model = property(get_model, set_model)

    ## Auto create form action for target menu item
    def get_form(self):
        if self.action and self.action.action_type == 'form':
            return FormAction.objects.get(pk=self.action.pk).view

    def set_form(self, form):
        if isinstance(form, str):
            form = View.objects.get(name=form)
        action = FormAction.objects.create(name='%s "%s"' %
                                           ('showform', form.name),
                                           view=form)
        self.action = action
        self.image = '/static/keops/icons/page.png'

    form = property(get_form, set_form)

    ## Auto create report action for target menu item
    def get_report(self):
        if self.action and self.action.action_type == 'report':
            return ReportAction.objects.get(pk=self.action.pk).report

    def set_report(self, report):
        if isinstance(report, str):
            try:
                rep = Report.objects.get(name=report)
            except:
                rep = Report.objects.create(name=report)
            report = rep
        action = ReportAction.objects.create(name='%s "%s"' %
                                             ('showreport', report.name),
                                             report=report)
        self.action = action
        self.image = '/static/keops/icons/page.png'

    report = property(get_report, set_report)
Esempio n. 27
0
class Company(Partner):
    address = models.TextField()
    employee = models.ForeignKey(Person)

    class Meta:
        proxy = True
Esempio n. 28
0
class CompanyModel(models.Model):
    company = models.ForeignKey(Company, verbose_name=_('company'), null=False)

    class Meta:
        abstract = True
Esempio n. 29
0
class ModuleElement(Element):
    module = models.ForeignKey(Module, verbose_name=_('module'))

    class Meta:
        db_table = 'base_module_element'