Skip to content

Commit

Permalink
Fix SMS Content Item Category Option
Browse files Browse the repository at this point in the history
  • Loading branch information
SharleneNdinda committed Sep 15, 2023
1 parent c0d588d commit 6993db1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
11 changes: 5 additions & 6 deletions mycarehub/content/migrations/0013_auto_20230913_1642.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@


class Migration(migrations.Migration):

dependencies = [
('content', '0012_alter_smscontentitemcategory_sequence_key'),
("content", "0012_alter_smscontentitemcategory_sequence_key"),
]

operations = [
migrations.AddField(
model_name='smscontentitemtag',
name='code',
model_name="smscontentitemtag",
name="code",
field=models.IntegerField(default=1),
preserve_default=False,
),
migrations.AlterUniqueTogether(
name='smscontentitemtag',
unique_together={('name', 'code')},
name="smscontentitemtag",
unique_together={("name", "code")},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@


class Migration(migrations.Migration):

dependencies = [
('content', '0013_auto_20230913_1642'),
("content", "0013_auto_20230913_1642"),
]

operations = [
migrations.AlterField(
model_name='smscontentitemcategory',
name='code',
model_name="smscontentitemcategory",
name="code",
field=models.CharField(max_length=32, unique=True),
),
]
14 changes: 1 addition & 13 deletions mycarehub/content/models/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.db import models
from django.utils.text import Truncator, slugify
from modelcluster.fields import ParentalManyToManyField
from wagtail.admin.panels import FieldPanel, FieldRowPanel, MultiFieldPanel, WagtailAdminPageForm
from wagtail.admin.panels import FieldPanel, FieldRowPanel, MultiFieldPanel
from wagtail.api import APIField
from wagtail.models import Page
from wagtail.search import index
Expand All @@ -15,16 +15,6 @@
LOGGER = logging.getLogger(__name__)


class SMSContentItemPageForm(WagtailAdminPageForm):
def __init__(
self, data=None, files=None, parent_page=None, subscription=None, *args, **kwargs
): # pragma: no cover
super().__init__(data, files, parent_page, subscription, *args, **kwargs)
self.fields["category"].queryset = self.fields["category"].queryset.filter(
organisation=self.for_user.organisation, programs=parent_page.specific.program
)


class SMSContentItemCategory(AbstractBase):
"""Category associated with an SMS."""

Expand Down Expand Up @@ -136,8 +126,6 @@ class SMSContentItem(Page):
index.SearchField("swahili_content"),
]

base_form_class = SMSContentItemPageForm

# this configuration allows these custom fields to be available over the API
api_fields = [
APIField("live"),
Expand Down

0 comments on commit 6993db1

Please sign in to comment.