mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Add modal form for creating a new currency
This commit is contained in:
		| @@ -14,6 +14,7 @@ from company.urls import company_urls | ||||
| from company.urls import supplier_part_urls | ||||
| from company.urls import price_break_urls | ||||
|  | ||||
| from common.urls import common_urls | ||||
| from part.urls import part_urls | ||||
| from stock.urls import stock_urls | ||||
| from build.urls import build_urls | ||||
| @@ -70,6 +71,8 @@ urlpatterns = [ | ||||
|     url(r'^supplier-part/', include(supplier_part_urls)), | ||||
|     url(r'^price-break/', include(price_break_urls)), | ||||
|  | ||||
|     url(r'^common/', include(common_urls)), | ||||
|  | ||||
|     url(r'^stock/', include(stock_urls)), | ||||
|  | ||||
|     url(r'^company/', include(company_urls)), | ||||
|   | ||||
							
								
								
									
										24
									
								
								InvenTree/common/forms.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								InvenTree/common/forms.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| """ | ||||
| Django forms for interacting with common objects | ||||
| """ | ||||
|  | ||||
| # -*- coding: utf-8 -*- | ||||
| from __future__ import unicode_literals | ||||
|  | ||||
| from InvenTree.forms import HelperForm | ||||
|  | ||||
| from .models import Currency | ||||
|  | ||||
|  | ||||
| class CurrencyEditForm(HelperForm): | ||||
|     """ Form for creating / editing a currency object """ | ||||
|  | ||||
|     class Meta: | ||||
|         model = Currency | ||||
|         fields = [ | ||||
|             'symbol', | ||||
|             'suffix', | ||||
|             'description', | ||||
|             'value', | ||||
|             'base' | ||||
|         ] | ||||
							
								
								
									
										15
									
								
								InvenTree/common/urls.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								InvenTree/common/urls.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| """ | ||||
| URL lookup for common views | ||||
| """ | ||||
|  | ||||
| from django.conf.urls import url, include | ||||
|  | ||||
| from . import views | ||||
|  | ||||
| currency_urls = [ | ||||
|     url(r'^new/', views.CurrencyCreate.as_view(), name='currency-create'), | ||||
| ] | ||||
|  | ||||
| common_urls = [ | ||||
|     url(r'currency/', include(currency_urls)), | ||||
| ] | ||||
| @@ -1 +1,19 @@ | ||||
| # Create your views here. | ||||
| """ | ||||
| Django views for interacting with common models | ||||
| """ | ||||
|  | ||||
| # -*- coding: utf-8 -*- | ||||
| from __future__ import unicode_literals | ||||
|  | ||||
| from InvenTree.views import AjaxCreateView | ||||
|  | ||||
| from .models import Currency | ||||
| from .forms import CurrencyEditForm | ||||
|  | ||||
|  | ||||
| class CurrencyCreate(AjaxCreateView): | ||||
|     """ View for creating a new Currency object """ | ||||
|  | ||||
|     model = Currency | ||||
|     form_class = CurrencyEditForm | ||||
|     ajax_form_title = 'Create new Currency' | ||||
|   | ||||
| @@ -8,7 +8,11 @@ | ||||
|  | ||||
| <h4>Currencies</h4> | ||||
|  | ||||
| <table class='table table-striped table-condensed' id='currency-table'/> | ||||
| <div id='currency-buttons'> | ||||
|     <button class='btn btn-success' id='new-currency'>New Currency</button> | ||||
| </div> | ||||
|  | ||||
| <table class='table table-striped table-condensed' id='currency-table' data-toolbar='#currency-buttons'> | ||||
| </table> | ||||
| {% endblock %} | ||||
|  | ||||
| @@ -58,5 +62,12 @@ | ||||
|         ] | ||||
|     }); | ||||
|  | ||||
|     $("#new-currency").click(function() { | ||||
|         launchModalForm("{% url 'currency-create' %}", { | ||||
|             success: function() { | ||||
|                 $("#currency-table").bootstrapTable('refresh'); | ||||
|             }, | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
| {% endblock %} | ||||
		Reference in New Issue
	
	Block a user