-
Notifications
You must be signed in to change notification settings - Fork 1
Add a "Tag" model for event classification (Issue #161). #176
base: develop
Are you sure you want to change the base?
Changes from 1 commit
31cf42a
47be338
48f0911
a1f3ec4
cc64cfa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,46 @@ def get_path_for_flier(instance, filename): | |
| ) | ||
|
|
||
|
|
||
| class Tag(models.Model): | ||
| """ | ||
| Class used for adding classification tags on events. | ||
| """ | ||
|
|
||
| #: The name of the tag that is displayed on the event creation form; represented | ||
|
||
| #: as a CharField. | ||
| display_name = models.CharField( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have |
||
| verbose_name=_('Event Tag'), | ||
| help_text=_('Different categories for the event.'), | ||
|
||
| max_length=256, | ||
| ) | ||
|
|
||
| #: Unique id of the tag; represented as an IntegerField. | ||
| id = models.IntegerField( | ||
|
||
| verbose_name=_('ID'), | ||
| help_text=_('Unique ID of the tag.'), | ||
| primary_key=True, | ||
| ) | ||
|
|
||
| #: If the tag should be diplayed on the event creation form; represented as a | ||
| #: BooleanField. | ||
| display = models.BooleanField( | ||
|
||
| verbose_name=_('Display'), | ||
| help_text=_('Whether or not the tag is to be displayed on the event creation form.'), | ||
| default = True, | ||
| ) | ||
|
|
||
|
|
||
| def __str__(self): | ||
| """ | ||
| Changes what is displayed for each tag on the event creation | ||
|
||
| form (without this it shows 'Tag object (id)'). | ||
|
|
||
| :return: String containing the name of the tag. | ||
|
||
| :rtype: string. | ||
|
||
| """ | ||
| return self.display_name | ||
|
|
||
|
|
||
| class Event(models.Model): | ||
| """ | ||
| Class used to define what is needed when creating new events. | ||
|
|
@@ -154,6 +194,13 @@ class Event(models.Model): | |
| blank=True, | ||
| ) | ||
|
|
||
| #: Tags available to attach to events; represented as a ManyToManyField. | ||
| tags = models.ManyToManyField( | ||
| Tag, | ||
| verbose_name=_('Event Tags'), | ||
| help_text=_('Different categories for classifying the event.'), | ||
| ) | ||
|
|
||
| @property | ||
| def is_active(self): | ||
| """ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid using
Classhere and rephrase this docstring.