-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(itim): Ability to add and configure Cluster Types
- Loading branch information
Showing
10 changed files
with
405 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from django import forms | ||
from django.forms import ValidationError | ||
from django.urls import reverse | ||
|
||
from itim.models.clusters import ClusterType | ||
|
||
from app import settings | ||
|
||
from core.forms.common import CommonModelForm | ||
|
||
|
||
|
||
class ClusterTypeForm(CommonModelForm): | ||
|
||
|
||
class Meta: | ||
|
||
fields = '__all__' | ||
|
||
model = ClusterType | ||
|
||
prefix = 'cluster_type' | ||
|
||
def __init__(self, *args, **kwargs): | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
|
||
|
||
class DetailForm(ClusterTypeForm): | ||
|
||
|
||
tabs: dict = { | ||
"details": { | ||
"name": "Details", | ||
"slug": "details", | ||
"sections": [ | ||
{ | ||
"layout": "double", | ||
"left": [ | ||
'name', | ||
'organization', | ||
'c_created', | ||
'c_modified' | ||
], | ||
"right": [ | ||
'model_notes', | ||
] | ||
}, | ||
] | ||
}, | ||
"notes": { | ||
"name": "Notes", | ||
"slug": "notes", | ||
"sections": [] | ||
} | ||
} | ||
|
||
|
||
def __init__(self, *args, **kwargs): | ||
|
||
super().__init__(*args, **kwargs) | ||
|
||
|
||
self.fields['c_created'] = forms.DateTimeField( | ||
label = 'Created', | ||
input_formats=settings.DATETIME_FORMAT, | ||
disabled = True, | ||
initial = self.instance.created, | ||
) | ||
|
||
self.fields['c_modified'] = forms.DateTimeField( | ||
label = 'Modified', | ||
input_formats=settings.DATETIME_FORMAT, | ||
disabled = True, | ||
initial = self.instance.modified, | ||
) | ||
|
||
self.tabs['details'].update({ | ||
"edit_url": reverse('Settings:_cluster_type_change', args=(self.instance.pk,)) | ||
}) | ||
|
||
self.url_index_view = reverse('Settings:_cluster_types') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
app/itim/migrations/0002_clustertype_created_clustertype_modified.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Django 5.0.7 on 2024-08-18 03:57 | ||
|
||
import access.fields | ||
import django.utils.timezone | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('itim', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='clustertype', | ||
name='created', | ||
field=access.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False), | ||
), | ||
migrations.AddField( | ||
model_name='clustertype', | ||
name='modified', | ||
field=access.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% extends 'detail.html.j2' %} | ||
|
||
{% load json %} | ||
{% load markdown %} | ||
|
||
|
||
{% block tabs %} | ||
|
||
<div id="details" class="content-tab"> | ||
|
||
{% include 'content/section.html.j2' with tab=form.tabs.details %} | ||
|
||
</div> | ||
|
||
|
||
<div id="notes" class="content-tab"> | ||
|
||
{% include 'content/section.html.j2' with tab=form.tabs.notes %} | ||
|
||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{% extends 'base.html.j2' %} | ||
|
||
{% block content %} | ||
|
||
<input type="button" value="New Cluster Type" onclick="window.location='{% url 'Settings:_cluster_type_add' %}';"> | ||
<table class="data"> | ||
<tr> | ||
<th>Title</th> | ||
<th> </th> | ||
<th>Organization</th> | ||
<th> </th> | ||
</tr> | ||
{% if items %} | ||
{% for item in items %} | ||
<tr> | ||
<td><a href="{% url 'Settings:_cluster_type_view' pk=item.id %}">{{ item.name }}</a></td> | ||
<td> </td> | ||
<td>{{ item.organization }}</td> | ||
<td> </td> | ||
</tr> | ||
{% endfor %} | ||
{% else %} | ||
<tr> | ||
<td colspan="4">Nothing Found</td> | ||
</tr> | ||
{% endif %} | ||
</table> | ||
<br> | ||
<div class="pagination"> | ||
<span class="step-links"> | ||
{% if page_obj.has_previous %} | ||
<a href="?page=1">« first</a> | ||
<a href="?page={{ page_obj.previous_page_number }}">previous</a> | ||
{% endif %} | ||
|
||
<span class="current"> | ||
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. | ||
</span> | ||
|
||
{% if page_obj.has_next %} | ||
<a href="?page={{ page_obj.next_page_number }}">next</a> | ||
<a href="?page={{ page_obj.paginator.num_pages }}">last »</a> | ||
{% endif %} | ||
</span> | ||
</div> | ||
|
||
{% endblock %} |
Oops, something went wrong.