diff --git a/action/forms.py b/action/forms.py new file mode 100644 index 0000000..4d391f2 --- /dev/null +++ b/action/forms.py @@ -0,0 +1,22 @@ +from django import forms +from .models import State + + +class AddStateForm(forms.Form): + add_note = forms.BooleanField(required=False) + note = forms.CharField( + required=False, + widget=forms.Textarea(attrs={'rows': 4, 'maxlength': 200, 'placeholder': 'Max 200 characters'}), + ) + state_id = forms.IntegerField(required=True, widget=forms.HiddenInput()) + snapshot_uuid = forms.UUIDField(required=True, widget=forms.HiddenInput()) + + + def clean(self): + cleaned_data = super().clean() + add_note = cleaned_data.get('add_note') + note = cleaned_data.get('note') + + if add_note == True and not note: + self.add_error('note', 'Please enter a note if you checked "Add a note".') + return cleaned_data \ No newline at end of file diff --git a/device/templates/details.html b/device/templates/details.html index 3c0a185..e38e229 100644 --- a/device/templates/details.html +++ b/device/templates/details.html @@ -58,70 +58,91 @@ - -
+
-
{% trans 'Details' %}
-
-
Phid
-
{{ object.id }}
-
- - {% if object.is_eraseserver %} -
-
- {% trans 'Is a erase server' %} -
-
-
- {% endif %} - -
-
Type
-
{{ object.type }}
-
- - {% if object.is_websnapshot and object.last_user_evidence %} - {% for k, v in object.last_user_evidence %} +
+ +
+
{% trans 'Details' %}
+
-
{{ k }}
-
{{ v|default:'' }}
+
{% trans 'Phid' %}
+
{{ object.id }}
- {% endfor %} - {% else %} -
-
- {% trans 'Manufacturer' %} + + {% if object.is_eraseserver %} +
+
{% trans 'Is an erase server' %}
+
{% trans 'Yes' %}
+
+ {% endif %} + +
+
{% trans 'Type' %}
+
{{ object.type }}
+
+ + {% if object.is_websnapshot and object.last_user_evidence %} + {% for k, v in object.last_user_evidence.items %} +
+
{{ k }}
+
{{ v|default:'' }}
+
+ {% endfor %} + {% else %} +
+
{% trans 'Manufacturer' %}
+
{{ object.manufacturer|default:'' }}
+
+ +
+
{% trans 'Model' %}
+
{{ object.model|default:'' }}
+
+ +
+
{% trans 'Serial Number' %}
+
{{ object.serial_number|default:'' }}
+
+ {% endif %} + +
+
{% trans 'Identifiers' %}
+
+ {% for chid in object.hids %} +
{{ chid|default:'' }}
+ {% endfor %} +
-
{{ object.manufacturer|default:'' }}
- -
-
- {% trans 'Model' %} + + + +
+
{% trans 'Current State' %}
+
+
+
{% trans 'State' %}
+
{{ device_states.0.state }}
-
{{ object.model|default:'' }}
-
- -
-
- {% trans 'Serial Number' %} +
+
{% trans 'Date' %}
+
{{ device_states.0.date|date:"SHORT_DATETIME_FORMAT" }}
-
{{ object.serial_number|default:'' }}
-
- {% endif %} -
-
- {% trans 'Identifiers' %} + + {% if last_note %} +
+
{% trans 'Note' %}
+
{{ object.last_state.note }}
+
+ {% endif %}
- {% for chid in object.hids %} -
-
{{ chid|default:'' }}
-
- {% endfor %}
+
+ +
@@ -169,7 +190,7 @@
- + {% for a in object.get_user_properties %}