Skip to content
This repository was archived by the owner on Jul 7, 2019. It is now read-only.

Commit a90f993

Browse files
committed
Add functionality to disabled a tag on event form.
1 parent bd6423a commit a90f993

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

ACM_General/events/forms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class Meta:
2424
'date_expire': DateTimeInput(attrs={'id': 'calendar'}),
2525
'title': Textarea(attrs={'rows': 3}),
2626
'description': Textarea(attrs={'rows': 3}),
27-
'link': TextInput(),
27+
'link': TextInput(),
2828
'tags': CheckboxSelectMultiple(),
2929
}
30+
def __init__(self, **kwargs):
31+
super(EventForm, self).__init__(**kwargs)
32+
self.fields['tags'].queryset = Tag.objects.filter(is_disabled=False)

ACM_General/events/models.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,40 +49,36 @@ def get_path_for_flier(instance, filename):
4949

5050
class Tag(models.Model):
5151
"""
52-
Class used for adding classification tags on events.
52+
Model used for adding tags on events.
5353
"""
5454

55-
#: The name of the tag that is displayed on the event creation form; represented
56-
#: as a CharField.
55+
#: The name of the tag that is displayed; represented as a CharField.
5756
display_name = models.CharField(
5857
verbose_name=_('Event Tag'),
59-
help_text=_('Different categories for the event.'),
58+
help_text=_('The name of the tag that will be displayed to users.'),
59+
unique=True,
6060
max_length=256,
6161
)
6262

63-
#: Unique id of the tag; represented as an IntegerField.
64-
id = models.IntegerField(
63+
#: Unique id of the tag; represented as an CharField.
64+
id = models.CharField(
6565
verbose_name=_('ID'),
6666
help_text=_('Unique ID of the tag.'),
6767
primary_key=True,
68+
max_length=256,
6869
)
6970

70-
#: If the tag should be diplayed on the event creation form; represented as a
71-
#: BooleanField.
72-
display = models.BooleanField(
71+
#: If the tag should be diplayed; represented as a BooleanField.
72+
is_disabled = models.BooleanField(
7373
verbose_name=_('Display'),
74-
help_text=_('Whether or not the tag is to be displayed on the event creation form.'),
74+
help_text=_('Whether or not the tag is to be displayed.'),
7575
default = True,
7676
)
7777

78-
7978
def __str__(self):
8079
"""
81-
Changes what is displayed for each tag on the event creation
82-
form (without this it shows 'Tag object (id)').
83-
84-
:return: String containing the name of the tag.
85-
:rtype: string.
80+
:returns: Display the name of the tag.
81+
:rtype: str
8682
"""
8783
return self.display_name
8884

@@ -198,7 +194,7 @@ class Event(models.Model):
198194
tags = models.ManyToManyField(
199195
Tag,
200196
verbose_name=_('Event Tags'),
201-
help_text=_('Different categories for classifying the event.'),
197+
help_text=_('The name of the Tag that will be displayed to users'),
202198
)
203199

204200
@property
@@ -207,7 +203,7 @@ def is_active(self):
207203
Checking whether or not an event has already expired
208204
(gone past the current date).
209205
210-
:return: Bool value representing whether or not the event is
206+
:returns: Bool value representing whether or not the event is
211207
considered 'active'.
212208
:rtype: bool
213209
"""
@@ -218,7 +214,7 @@ def clean(self):
218214
The clean function is used for making checks on the data posted to the
219215
form.
220216
221-
:return: None.
217+
:returns: None.
222218
:rtype: None
223219
224220
:raises ValidationError: if date_expire or date_hosted are invalid.

0 commit comments

Comments
 (0)