Skip to content

Commit

Permalink
feat: add faq model
Browse files Browse the repository at this point in the history
Signed-off-by: maxwellgithinji <maxwellgithinji@gmail.com>
  • Loading branch information
maxwellgithinji committed Dec 7, 2021
1 parent 1571ea6 commit 1137876
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mycarehub/common/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from mycarehub.common.models.common_models import Address, AuditLog, Contact
from mycarehub.common.models.common_models import FAQ, Address, AuditLog, Contact

from .models import Facility, FacilityAttachment, Organisation

Expand Down Expand Up @@ -68,3 +68,8 @@ class ContactAdmin(BaseAdmin):
@admin.register(AuditLog)
class AuditLogAdmin(BaseAdmin):
pass


@admin.register(FAQ)
class FAQAdmin(BaseAdmin):
pass
42 changes: 42 additions & 0 deletions mycarehub/common/migrations/0015_faq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 3.2.9 on 2021-12-07 11:01

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import mycarehub.common.models.base_models
import mycarehub.users.models
import uuid


class Migration(migrations.Migration):

dependencies = [
('common', '0014_facility_phone'),
]

operations = [
migrations.CreateModel(
name='FAQ',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('active', models.BooleanField(default=True)),
('created', models.DateTimeField(default=django.utils.timezone.now)),
('created_by', models.UUIDField(blank=True, null=True)),
('updated', models.DateTimeField(default=django.utils.timezone.now)),
('updated_by', models.UUIDField(blank=True, null=True)),
('deleted_at', models.DateTimeField(blank=True, null=True)),
('title', models.TextField(unique=True)),
('description', models.TextField(blank=True, null=True, unique=True)),
('body', models.TextField(unique=True)),
('flavour', models.CharField(blank=True, choices=[('PRO', 'PRO'), ('CONSUMER', 'CONSUMER')], max_length=32, null=True)),
('organisation', models.ForeignKey(default=mycarehub.users.models.default_organisation, on_delete=django.db.models.deletion.PROTECT, related_name='common_faq_related', to='common.organisation')),
],
options={
'ordering': ('-updated', '-created'),
'abstract': False,
},
managers=[
('objects', mycarehub.common.models.base_models.AbstractBaseManager()),
],
),
]
13 changes: 13 additions & 0 deletions mycarehub/common/models/common_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,16 @@ class AuditLog(AbstractBase):
record_type = models.TextField()
notes = models.TextField()
payload = JSONField()


class FAQ(AbstractBase):
class FlavourChoices(models.TextChoices):
PRO = "PRO", _("PRO")
CONSUMER = "CONSUMER", _("CONSUMER")

title = models.TextField(unique=True)
description = models.TextField(unique=True, null=True, blank=True)
body = models.TextField(unique=True)
flavour = models.CharField(
choices=FlavourChoices.choices, max_length=32, null=True, blank=True
)

0 comments on commit 1137876

Please sign in to comment.