migrate categories to a multiselect

This commit is contained in:
Ross
2024-02-26 11:45:39 +00:00
parent df632319f5
commit fdc7c6150b
5 changed files with 54 additions and 5 deletions
@@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-02-26 11:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rcr', '0019_alter_item_oncology_category_and_more'),
]
operations = [
migrations.AddField(
model_name='item',
name='radiology_categories',
field=models.ManyToManyField(blank=True, related_name='items_radiology', to='rcr.radiologycategory'),
),
]
+21
View File
@@ -0,0 +1,21 @@
# Generated by Django 5.0.2 on 2024-02-26 11:40
from django.db import migrations, models
def move_radiology_categories(apps, schema_editor):
Item = apps.get_model("rcr", "Item")
#RadiologyCategory = apps.get_model("rcr", "RadiologyCategory")
for item in Item.objects.all():
if item.radiology_category:
item.radiology_categories.add(item.radiology_category)
class Migration(migrations.Migration):
dependencies = [
('rcr', '0020_item_radiology_categories'),
]
operations = [
migrations.RunPython(move_radiology_categories),
]
+1
View File
@@ -37,6 +37,7 @@ class Item(models.Model):
rcr_platform_id = models.CharField(max_length=255, unique=True) rcr_platform_id = models.CharField(max_length=255, unique=True)
radiology_category = models.ForeignKey("RadiologyCategory", on_delete=models.SET_NULL, null=True, blank=True, related_name="item_radiology") radiology_category = models.ForeignKey("RadiologyCategory", on_delete=models.SET_NULL, null=True, blank=True, related_name="item_radiology")
radiology_categories = models.ManyToManyField("RadiologyCategory", blank=True, related_name="items_radiology")
oncology_category = models.ForeignKey("OncologyCategory", on_delete=models.SET_NULL, null=True, blank=True, related_name="item_oncology") oncology_category = models.ForeignKey("OncologyCategory", on_delete=models.SET_NULL, null=True, blank=True, related_name="item_oncology")
level = models.ManyToManyField("Level", blank=True) level = models.ManyToManyField("Level", blank=True)
+5 -1
View File
@@ -28,7 +28,7 @@
<table> <table>
<tr><th></th><th>Content Type</th><th>Name</th><th>Assessed<br/> By</th></tr> <tr><th></th><th>Content Type</th><th>Name</th><th>Assessed<br/> By</th></tr>
{% for item in items %} {% for item in items %}
<tr class="{{item.content_type}} {% if item.completed_radiology %} completed-radiology{% endif %}{% if item.completed_oncology %} completed-oncology{% endif %}"> <tr class="{{item.content_type}} {% if item.completed_radiology %} completed-radiology{% endif %}{% if item.completed_oncology %} completed-oncology{% endif %}{% if item.needs_review %} review{% endif %}">
<td class="{{item.specialty}}" title="{{item.specialty}}"> <td class="{{item.specialty}}" title="{{item.specialty}}">
{{forloop.counter}}: {{forloop.counter}}:
</td> </td>
@@ -57,6 +57,10 @@
{% block css %} {% block css %}
<style type="text/css"> <style type="text/css">
.review::after {
content: '(R)';
color: orange;
}
.completed-radiology::after { .completed-radiology::after {
content: '✓'; content: '✓';
color: green; color: green;
+5
View File
@@ -5,6 +5,11 @@
{% include "rcr/item_rcr_details.html" %} {% include "rcr/item_rcr_details.html" %}
<p>Radiology Category: {{object.radiology_category}}</p> <p>Radiology Category: {{object.radiology_category}}</p>
<p>Radiology Categories:
{% for category in object.radiology_categories.all %}
{{category}}
{% endfor %}
</p>
<p>Oncology Category: {{object.oncology_category}}</p> <p>Oncology Category: {{object.oncology_category}}</p>
<p> <p>