mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Edit currency from settings view
This commit is contained in:
parent
31562826f4
commit
3188b0ab18
@ -8,6 +8,9 @@ from . import views
|
||||
|
||||
currency_urls = [
|
||||
url(r'^new/', views.CurrencyCreate.as_view(), name='currency-create'),
|
||||
|
||||
url(r'^(?P<pk>\d+)/edit/', views.CurrencyEdit.as_view(), name='currency-edit'),
|
||||
#url(r'^(?P<pk>\d+)/delete/', views.CurrencyDelete.as_view(), name='currency-delete'),
|
||||
]
|
||||
|
||||
common_urls = [
|
||||
|
@ -5,15 +5,23 @@ Django views for interacting with common models
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from InvenTree.views import AjaxCreateView
|
||||
from InvenTree.views import AjaxCreateView, AjaxUpdateView
|
||||
|
||||
from .models import Currency
|
||||
from .forms import CurrencyEditForm
|
||||
from . import models
|
||||
from . import forms
|
||||
|
||||
|
||||
class CurrencyCreate(AjaxCreateView):
|
||||
""" View for creating a new Currency object """
|
||||
|
||||
model = Currency
|
||||
form_class = CurrencyEditForm
|
||||
model = models.Currency
|
||||
form_class = forms.CurrencyEditForm
|
||||
ajax_form_title = 'Create new Currency'
|
||||
|
||||
|
||||
class CurrencyEdit(AjaxUpdateView):
|
||||
""" View for editing an existing Currency object """
|
||||
|
||||
model = models.Currency
|
||||
form_class = forms.CurrencyEditForm
|
||||
ajax_form_title = 'Edit Currency'
|
||||
|
@ -58,10 +58,38 @@
|
||||
field: 'value',
|
||||
title: 'Value',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
formatter: function(value, row, index, field) {
|
||||
|
||||
var bEdit = "<button title='Edit Currency' class='cur-edit btn btn-default btn-glyph' type='button' pk='" + row.pk + "'><span class='glyphicon glyphicon-edit'></span></button>";
|
||||
var bDel = "<button title='Delete Currency' class='cur-delete btn btn-default btn-glyph' type='button' pk='" + row.pk + "'><span class='glyphicon glyphicon-trash'></span></button>";
|
||||
|
||||
var html = "<div class='btn-group' role='group'>" + bEdit + bDel + "</div>";
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$("#currency-table").on('click', '.cur-edit', function() {
|
||||
var button = $(this);
|
||||
var url = "/common/currency/" + button.attr('pk') + "/edit/";
|
||||
|
||||
launchModalForm(url, {
|
||||
success: function() {
|
||||
$("#currency-table").bootstrapTable('refresh');
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$("#currency-table").on('click', '.cur-delete', function() {
|
||||
var button = $(this);
|
||||
var url = "/common/currency/" + button.attr('pk') + "/delete/";
|
||||
|
||||
});
|
||||
|
||||
$("#new-currency").click(function() {
|
||||
launchModalForm("{% url 'currency-create' %}", {
|
||||
success: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user