mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 20:46:47 +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 = [
|
currency_urls = [
|
||||||
url(r'^new/', views.CurrencyCreate.as_view(), name='currency-create'),
|
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 = [
|
common_urls = [
|
||||||
|
@ -5,15 +5,23 @@ Django views for interacting with common models
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from InvenTree.views import AjaxCreateView
|
from InvenTree.views import AjaxCreateView, AjaxUpdateView
|
||||||
|
|
||||||
from .models import Currency
|
from . import models
|
||||||
from .forms import CurrencyEditForm
|
from . import forms
|
||||||
|
|
||||||
|
|
||||||
class CurrencyCreate(AjaxCreateView):
|
class CurrencyCreate(AjaxCreateView):
|
||||||
""" View for creating a new Currency object """
|
""" View for creating a new Currency object """
|
||||||
|
|
||||||
model = Currency
|
model = models.Currency
|
||||||
form_class = CurrencyEditForm
|
form_class = forms.CurrencyEditForm
|
||||||
ajax_form_title = 'Create new Currency'
|
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',
|
field: 'value',
|
||||||
title: 'Value',
|
title: 'Value',
|
||||||
sortable: true,
|
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() {
|
$("#new-currency").click(function() {
|
||||||
launchModalForm("{% url 'currency-create' %}", {
|
launchModalForm("{% url 'currency-create' %}", {
|
||||||
success: function() {
|
success: function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user