@ -37,17 +37,17 @@
|
|||||||
<button id="defaultOpen" class="tablinks" onclick="openCity(event, 'Details')">Details</button>
|
<button id="defaultOpen" class="tablinks" onclick="openCity(event, 'Details')">Details</button>
|
||||||
<button id="defaultOpen" class="tablinks" onclick="openCity(event, 'Versions')">Versions</button>
|
<button id="defaultOpen" class="tablinks" onclick="openCity(event, 'Versions')">Versions</button>
|
||||||
<button class="tablinks" onclick="openCity(event, 'Licences')">Licences</button>
|
<button class="tablinks" onclick="openCity(event, 'Licences')">Licences</button>
|
||||||
|
<button class="tablinks" onclick="openCity(event, 'Notes')">Notes</button>
|
||||||
<button class="tablinks" onclick="openCity(event, 'Installations')">Installations</button>
|
<button class="tablinks" onclick="openCity(event, 'Installations')">Installations</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tab content -->
|
<form method="post">
|
||||||
<div id="Details" class="tabcontent">
|
<div id="Details" class="tabcontent">
|
||||||
<h3>Details</h3>
|
<h3>Details</h3>
|
||||||
<form method="post">
|
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form }}
|
{{ form }}
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Get the element with id="defaultOpen" and click on it
|
// Get the element with id="defaultOpen" and click on it
|
||||||
@ -108,6 +108,23 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="Notes" class="tabcontent">
|
||||||
|
<h3>
|
||||||
|
Notes
|
||||||
|
</h3>
|
||||||
|
{{ notes_form }}
|
||||||
|
<input type="submit" name="{{notes_form.prefix}}" value="Submit" />
|
||||||
|
<div class="comments">
|
||||||
|
{% if notes %}
|
||||||
|
{% for note in notes%}
|
||||||
|
{% include 'note.html.j2' %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="Installations" class="tabcontent">
|
<div id="Installations" class="tabcontent">
|
||||||
<h3>Installations</h3>
|
<h3>Installations</h3>
|
||||||
<table>
|
<table>
|
||||||
@ -157,6 +174,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -4,6 +4,9 @@ from django.views import generic
|
|||||||
|
|
||||||
from access.mixin import OrganizationPermission
|
from access.mixin import OrganizationPermission
|
||||||
|
|
||||||
|
from core.forms.comment import AddNoteForm
|
||||||
|
from core.models.notes import Notes
|
||||||
|
|
||||||
from itam.models.device import DeviceSoftware
|
from itam.models.device import DeviceSoftware
|
||||||
from itam.models.software import Software, SoftwareVersion
|
from itam.models.software import Software, SoftwareVersion
|
||||||
from itam.forms.software.update import Update as SoftwareUpdate_Form
|
from itam.forms.software.update import Update as SoftwareUpdate_Form
|
||||||
@ -40,6 +43,7 @@ class View(OrganizationPermission, generic.UpdateView):
|
|||||||
|
|
||||||
context_object_name = "software"
|
context_object_name = "software"
|
||||||
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
@ -51,6 +55,9 @@ class View(OrganizationPermission, generic.UpdateView):
|
|||||||
|
|
||||||
context['software_versions'] = software_versions
|
context['software_versions'] = software_versions
|
||||||
|
|
||||||
|
context['notes_form'] = AddNoteForm(prefix='note')
|
||||||
|
context['notes'] = Notes.objects.filter(software=self.kwargs['pk'])
|
||||||
|
|
||||||
context['content_title'] = self.object.name
|
context['content_title'] = self.object.name
|
||||||
|
|
||||||
if self.request.user.is_superuser:
|
if self.request.user.is_superuser:
|
||||||
@ -73,6 +80,27 @@ class View(OrganizationPermission, generic.UpdateView):
|
|||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
|
||||||
|
software = Software.objects.get(pk=self.kwargs['pk'])
|
||||||
|
|
||||||
|
notes = AddNoteForm(request.POST, prefix='note')
|
||||||
|
|
||||||
|
if notes.is_bound and notes.is_valid():
|
||||||
|
|
||||||
|
notes.instance.organization = software.organization
|
||||||
|
notes.instance.software = software
|
||||||
|
notes.instance.usercreated = request.user
|
||||||
|
|
||||||
|
notes.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return super().post(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def get_success_url(self, **kwargs):
|
def get_success_url(self, **kwargs):
|
||||||
|
|
||||||
return f"/itam/software/{self.kwargs['pk']}/"
|
return f"/itam/software/{self.kwargs['pk']}/"
|
||||||
|
Reference in New Issue
Block a user