@ -56,7 +56,7 @@
|
||||
|
||||
<div id="Versions" class="tabcontent">
|
||||
<h3>Versions</h3>
|
||||
Not Yet Implemented
|
||||
<input type="button" value="New Software Version" onclick="window.location='{% url 'ITAM:_software_version_add' pk=software.id %}';">
|
||||
<table>
|
||||
<thead>
|
||||
<th>Version</th>
|
||||
@ -65,9 +65,12 @@
|
||||
<th> </th>
|
||||
</thead>
|
||||
<tr>
|
||||
<td>1.0.0</td>
|
||||
<td>5</td>
|
||||
<td><input type="checkbox" checked disabled></td>
|
||||
{% for version in software_versions %}
|
||||
<td>{{ version.name }}</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
from .views import device, device_type, software, software_category
|
||||
from .views import device, device_type, software, software_category, software_version
|
||||
|
||||
app_name = "ITAM"
|
||||
urlpatterns = [
|
||||
@ -20,6 +20,7 @@ urlpatterns = [
|
||||
path("software/", software.IndexView.as_view(), name="Software"),
|
||||
path("software/<int:pk>/", software.View.as_view(), name="_software_view"),
|
||||
path("software/<int:pk>/delete", software.Delete.as_view(), name="_software_delete"),
|
||||
path("software/<int:pk>/version/add", software_version.Add.as_view(), name="_software_version_add"),
|
||||
path("software/add/", software.Add.as_view(), name="_software_add"),
|
||||
|
||||
path("software_category/add/", software_category.Add.as_view(), name="_software_category_add"),
|
||||
|
@ -5,7 +5,7 @@ from django.views import generic
|
||||
from access.mixin import OrganizationPermission
|
||||
|
||||
from itam.models.device import DeviceSoftware
|
||||
from itam.models.software import Software
|
||||
from itam.models.software import Software, SoftwareVersion
|
||||
from itam.forms.software.update import Update as SoftwareUpdate_Form
|
||||
|
||||
class IndexView(PermissionRequiredMixin, OrganizationPermission, generic.ListView):
|
||||
@ -43,6 +43,10 @@ class View(OrganizationPermission, generic.UpdateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
software_versions = SoftwareVersion.objects.filter(software=self.kwargs['pk'])
|
||||
|
||||
context['software_versions'] = software_versions
|
||||
|
||||
context['content_title'] = self.object.name
|
||||
|
||||
if self.request.user.is_superuser:
|
||||
|
38
app/itam/views/software_version.py
Normal file
38
app/itam/views/software_version.py
Normal file
@ -0,0 +1,38 @@
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.views import generic
|
||||
|
||||
from access.mixin import OrganizationPermission
|
||||
|
||||
from ..models.software import Software, SoftwareVersion
|
||||
|
||||
|
||||
|
||||
class Add(PermissionRequiredMixin, OrganizationPermission, generic.CreateView):
|
||||
model = SoftwareVersion
|
||||
permission_required = [
|
||||
'access.add_softwareversion',
|
||||
]
|
||||
template_name = 'form.html.j2'
|
||||
fields = [
|
||||
'name'
|
||||
]
|
||||
|
||||
def form_valid(self, form):
|
||||
software = Software.objects.get(pk=self.kwargs['pk'])
|
||||
|
||||
form.instance.organization_id = software.organization.id
|
||||
form.instance.software_id = self.kwargs['pk']
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
def get_success_url(self, **kwargs):
|
||||
|
||||
return f"/itam/software/{self.kwargs['pk']}/"
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context['content_title'] = 'Add Software Version'
|
||||
|
||||
return context
|
Reference in New Issue
Block a user