Skip to content

Conversation

@mtahirtariq
Copy link

Adds:

  • ContentType ForeignKey in Attribute Model
  • Update Entity class to pass entity to get_all_attributes method.
  • Add new Attribute field types
    • decimal
    • enum_multi

Motivation and Context

Attributes are shared across all the models which register with them. This PR adds support to assign specific Attributes to specific models.

Types of Changes

  • What types of changes does your code introduce? Put an x in all the boxes that apply:
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

Go over all the following points, and put an x in all the boxes that apply.
If you're unsure about any of these, don't hesitate to ask. We're here to help!

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@mtahirtariq mtahirtariq force-pushed the attribute-contenttype branch from 1f0cdaa to 9a56b8a Compare July 27, 2020 07:52
@mtahirtariq mtahirtariq requested a review from ragdubizzle July 27, 2020 07:53
"""
value = models.CharField(_('Value'), db_index=True, unique=True, max_length=50)
value = models.CharField(_('Value'), db_index=True, max_length=100)
legacy_value = models.CharField(_('Legacy Value'), blank=True, null=True, db_index=True, max_length=100)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this field?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be used to synchronize existing data.

Comment on lines +137 to +145
TYPE_TEXT = 'text'
TYPE_FLOAT = 'float'
TYPE_DECIMAL = 'decimal'
TYPE_INT = 'int'
TYPE_DATE = 'date'
TYPE_BOOLEAN = 'bool'
TYPE_OBJECT = 'object'
TYPE_ENUM = 'enum'
TYPE_ENUM_MULTI = 'enum_multi'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of aligning is against pep8, no?

blank=True,
null=True,
)
entity_id = models.UUIDField(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a UUID field?

# Core attributes
entity_ct = models.ForeignKey(
ContentType,
on_delete = models.PROTECT,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too many spaces before =

Comment on lines +172 to +173
ct_field = 'entity_ct',
fk_field = 'entity_id'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space around =

@mtahirtariq mtahirtariq merged commit f55f918 into master Sep 9, 2020
@mtahirtariq mtahirtariq deleted the attribute-contenttype branch September 9, 2020 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants