Display / editing for Company notes field

- Also includes some translation updates
This commit is contained in:
Oliver Walters 2020-02-01 23:45:28 +11:00
parent ca9f9e047c
commit 51fab36074
10 changed files with 209 additions and 85 deletions

View File

@ -27,7 +27,6 @@ class EditCompanyForm(HelperForm):
'contact', 'contact',
'is_customer', 'is_customer',
'is_supplier', 'is_supplier',
'notes'
] ]

View File

@ -18,13 +18,6 @@
</tr> </tr>
</table> </table>
{% if company.notes %}
<div class="panel panel-default">
<div class="panel-heading"><b>Notes</b></div>
<div class="panel-body">{{ company.notes }}</div>
</div>
{% endif %}
{% endblock %} {% endblock %}
{% block js_ready %} {% block js_ready %}
{{ block.super }} {{ block.super }}

View File

@ -0,0 +1,53 @@
{% extends "company/company_base.html" %}
{% load static %}
{% load i18n %}
{% block details %}
{% load markdownify %}
{% include 'company/tabs.html' with tab='notes' %}
{% if editing %}
<h4>{% trans "Company Notes" %}</h4>
<hr>
<form method='POST'>
{% csrf_token %}
{{ form }}
<hr>
<input type="submit" value='{% trans "Save" %}'/>
</form>
{{ form.media }}
{% else %}
<div class='row'>
<div class='col-sm-6'>
<h4>{% trans "Company Notes" %}</h4>
</div>
<div class='col-sm-6'>
<button title='{% trans "Edit notes" %}' class='btn btn-default btn-glyph float-right' id='edit-notes'><span class='glyphicon glyphicon-edit'></span></button>
</div>
</div>
<hr>
<div class='panel panel-default'>
<div class='panel-content'>
{{ company.notes | markdownify }}
</div>
</div>
{% endif %}
{% endblock %}
{% block js_ready %}
{{ block.super }}
{% if editing %}
{% else %}
$("#edit-notes").click(function() {
location.href = "{% url 'company-notes' company.id %}?edit=1";
});
{% endif %}
{% endblock %}

View File

@ -1,23 +1,28 @@
{% load i18n %}
<ul class='nav nav-tabs'> <ul class='nav nav-tabs'>
<li{% if tab == 'details' %} class='active'{% endif %}> <li{% if tab == 'details' %} class='active'{% endif %}>
<a href="{% url 'company-detail' company.id %}">Details</a> <a href="{% url 'company-detail' company.id %}">{% trans "Details" %}</a>
</li> </li>
{% if company.is_supplier %} {% if company.is_supplier %}
<li{% if tab == 'parts' %} class='active'{% endif %}> <li{% if tab == 'parts' %} class='active'{% endif %}>
<a href="{% url 'company-detail-parts' company.id %}">Supplier Parts <span class='badge'>{{ company.part_count }}</span></a> <a href="{% url 'company-detail-parts' company.id %}">{% trans "Supplier Parts" %} <span class='badge'>{{ company.part_count }}</span></a>
</li> </li>
<li{% if tab == 'stock' %} class='active'{% endif %}> <li{% if tab == 'stock' %} class='active'{% endif %}>
<a href="{% url 'company-detail-stock' company.id %}">Stock <span class='badge'>{{ company.stock_count }}</a> <a href="{% url 'company-detail-stock' company.id %}">{% trans "Stock" %} <span class='badge'>{{ company.stock_count }}</a>
</li> </li>
<li{% if tab == 'po' %} class='active'{% endif %}> <li{% if tab == 'po' %} class='active'{% endif %}>
<a href="{% url 'company-detail-purchase-orders' company.id %}">Purchase Orders <span class='badge'>{{ company.purchase_orders.count }}</span></a> <a href="{% url 'company-detail-purchase-orders' company.id %}">{% trans "Purchase Orders" %} <span class='badge'>{{ company.purchase_orders.count }}</span></a>
</li> </li>
{% endif %} {% endif %}
{% if company.is_customer %} {% if company.is_customer %}
{% if 0 %} {% if 0 %}
<li{% if tab == 'co' %} class='active'{% endif %}> <li{% if tab == 'co' %} class='active'{% endif %}>
<a href="#">Sales Orders</a> <a href="#">{% trans "Sales Orders" %}</a>
</li> </li>
{% endif %} {% endif %}
{% endif %} {% endif %}
<li{% if tab == 'notes' %} class='active'{% endif %}>
<a href="{% url 'company-notes' company.id %}">{% trans "Notes" %}</a>
</li>
</ul> </ul>

View File

@ -18,6 +18,7 @@ company_detail_urls = [
url(r'parts/?', views.CompanyDetail.as_view(template_name='company/detail_part.html'), name='company-detail-parts'), url(r'parts/?', views.CompanyDetail.as_view(template_name='company/detail_part.html'), name='company-detail-parts'),
url(r'stock/?', views.CompanyDetail.as_view(template_name='company/detail_stock.html'), name='company-detail-stock'), url(r'stock/?', views.CompanyDetail.as_view(template_name='company/detail_stock.html'), name='company-detail-stock'),
url(r'purchase-orders/?', views.CompanyDetail.as_view(template_name='company/detail_purchase_orders.html'), name='company-detail-purchase-orders'), url(r'purchase-orders/?', views.CompanyDetail.as_view(template_name='company/detail_purchase_orders.html'), name='company-detail-purchase-orders'),
url(r'notes/?', views.CompanyNotes.as_view(), name='company-notes'),
url(r'thumbnail/?', views.CompanyImage.as_view(), name='company-image'), url(r'thumbnail/?', views.CompanyImage.as_view(), name='company-image'),

View File

@ -6,8 +6,9 @@ Django views for interacting with Company app
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
from django.views.generic import DetailView, ListView from django.views.generic import DetailView, ListView, UpdateView
from django.urls import reverse
from django.forms import HiddenInput from django.forms import HiddenInput
from InvenTree.views import AjaxCreateView, AjaxUpdateView, AjaxDeleteView from InvenTree.views import AjaxCreateView, AjaxUpdateView, AjaxDeleteView
@ -52,6 +53,28 @@ class CompanyIndex(ListView):
return queryset return queryset
class CompanyNotes(UpdateView):
""" View for editing the 'notes' field of a Company object.
"""
context_object_name = 'company'
template_name = 'company/notes.html'
model = Company
fields = ['notes']
def get_success_url(self):
return reverse('company-notes', kwargs={'pk': self.get_object().id})
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx['editing'] = str2bool(self.request.GET.get('edit', ''))
return ctx
class CompanyDetail(DetailView): class CompanyDetail(DetailView):
""" Detail view for Company object """ """ Detail view for Company object """
context_obect_name = 'company' context_obect_name = 'company'

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-01 12:31+0000\n" "POT-Creation-Date: 2020-02-01 12:45+0000\n"
"PO-Revision-Date: 2019-12-19 17:48+0100\n" "PO-Revision-Date: 2019-12-19 17:48+0100\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -385,7 +385,8 @@ msgstr "Standard-Zulieferer?"
msgid "Supplier part description" msgid "Supplier part description"
msgstr "Beschreibung des Teils" msgstr "Beschreibung des Teils"
#: company/models.py:248 order/templates/order/purchase_order_detail.html:168 #: company/models.py:248 company/templates/company/tabs.html:26
#: order/templates/order/purchase_order_detail.html:168
#: part/templates/part/tabs.html:58 stock/templates/stock/item.html:151 #: part/templates/part/tabs.html:58 stock/templates/stock/item.html:151
msgid "Notes" msgid "Notes"
msgstr "Notizen" msgstr "Notizen"
@ -400,11 +401,52 @@ msgstr "Minimal zulässiger Lagerbestand"
msgid "Part packaging" msgid "Part packaging"
msgstr "" msgstr ""
#: company/templates/company/notes.html:10
#: company/templates/company/notes.html:27
#, fuzzy
#| msgid "Company"
msgid "Company Notes"
msgstr "Firma"
#: company/templates/company/notes.html:17 part/templates/part/notes.html:20
msgid "Save"
msgstr ""
#: company/templates/company/notes.html:30 part/templates/part/notes.html:32
#, fuzzy
#| msgid "Entry notes"
msgid "Edit notes"
msgstr "Eintrags-Notizen"
#: company/templates/company/partdelete.html:5 #: company/templates/company/partdelete.html:5
msgid "Are you sure you want to delete the following Supplier Parts?" msgid "Are you sure you want to delete the following Supplier Parts?"
msgstr "" msgstr ""
"Sind Sie sicher, dass sie die folgenden Zulieferer-Teile löschen möchten?" "Sind Sie sicher, dass sie die folgenden Zulieferer-Teile löschen möchten?"
#: company/templates/company/tabs.html:5 part/templates/part/tabs.html:6
msgid "Details"
msgstr "Details"
#: company/templates/company/tabs.html:9
#, fuzzy
#| msgid "Supplier Part"
msgid "Supplier Parts"
msgstr "Zulieferer-Teil"
#: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17
msgid "Stock"
msgstr "Lagerbestand"
#: company/templates/company/tabs.html:15 part/templates/part/tabs.html:43
msgid "Purchase Orders"
msgstr "Bestellungen"
#: company/templates/company/tabs.html:21
#, fuzzy
#| msgid "Purchase Orders"
msgid "Sales Orders"
msgstr "Bestellungen"
#: order/forms.py:21 #: order/forms.py:21
msgid "Place order" msgid "Place order"
msgstr "Bestellung aufgeben" msgstr "Bestellung aufgeben"
@ -971,22 +1013,12 @@ msgstr "Teil kann an Kunden verkauft werden"
msgid "Part cannot be sold to customers" msgid "Part cannot be sold to customers"
msgstr "Teil kann nicht an Kunden verkauft werden" msgstr "Teil kann nicht an Kunden verkauft werden"
#: part/templates/part/notes.html:13 part/templates/part/notes.html:28 #: part/templates/part/notes.html:13 part/templates/part/notes.html:29
#, fuzzy #, fuzzy
#| msgid "Notes" #| msgid "Notes"
msgid "Part Notes" msgid "Part Notes"
msgstr "Notizen" msgstr "Notizen"
#: part/templates/part/notes.html:19
msgid "Save"
msgstr ""
#: part/templates/part/notes.html:31
#, fuzzy
#| msgid "Entry notes"
msgid "Edit notes"
msgstr "Eintrags-Notizen"
#: part/templates/part/part_base.html:11 #: part/templates/part/part_base.html:11
msgid "This part is not active" msgid "This part is not active"
msgstr "Dieses Teil ist nicht aktiv" msgstr "Dieses Teil ist nicht aktiv"
@ -1019,10 +1051,6 @@ msgstr "Herstellbar?"
msgid "Underway" msgid "Underway"
msgstr "unterwegs" msgstr "unterwegs"
#: part/templates/part/tabs.html:6
msgid "Details"
msgstr "Details"
#: part/templates/part/tabs.html:9 #: part/templates/part/tabs.html:9
msgid "Parameters" msgid "Parameters"
msgstr "Parameter" msgstr "Parameter"
@ -1031,10 +1059,6 @@ msgstr "Parameter"
msgid "Variants" msgid "Variants"
msgstr "Varianten" msgstr "Varianten"
#: part/templates/part/tabs.html:17
msgid "Stock"
msgstr "Lagerbestand"
#: part/templates/part/tabs.html:26 #: part/templates/part/tabs.html:26
msgid "BOM" msgid "BOM"
msgstr "Stückliste" msgstr "Stückliste"
@ -1051,10 +1075,6 @@ msgstr "Benutzt in"
msgid "Suppliers" msgid "Suppliers"
msgstr "Zulieferer" msgstr "Zulieferer"
#: part/templates/part/tabs.html:43
msgid "Purchase Orders"
msgstr "Bestellungen"
#: part/templates/part/tabs.html:48 #: part/templates/part/tabs.html:48
msgid "Tracking" msgid "Tracking"
msgstr "Tracking" msgstr "Tracking"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-01 12:31+0000\n" "POT-Creation-Date: 2020-02-01 12:45+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -357,7 +357,8 @@ msgstr ""
msgid "Supplier part description" msgid "Supplier part description"
msgstr "" msgstr ""
#: company/models.py:248 order/templates/order/purchase_order_detail.html:168 #: company/models.py:248 company/templates/company/tabs.html:26
#: order/templates/order/purchase_order_detail.html:168
#: part/templates/part/tabs.html:58 stock/templates/stock/item.html:151 #: part/templates/part/tabs.html:58 stock/templates/stock/item.html:151
msgid "Notes" msgid "Notes"
msgstr "" msgstr ""
@ -370,10 +371,43 @@ msgstr ""
msgid "Part packaging" msgid "Part packaging"
msgstr "" msgstr ""
#: company/templates/company/notes.html:10
#: company/templates/company/notes.html:27
msgid "Company Notes"
msgstr ""
#: company/templates/company/notes.html:17 part/templates/part/notes.html:20
msgid "Save"
msgstr ""
#: company/templates/company/notes.html:30 part/templates/part/notes.html:32
msgid "Edit notes"
msgstr ""
#: company/templates/company/partdelete.html:5 #: company/templates/company/partdelete.html:5
msgid "Are you sure you want to delete the following Supplier Parts?" msgid "Are you sure you want to delete the following Supplier Parts?"
msgstr "" msgstr ""
#: company/templates/company/tabs.html:5 part/templates/part/tabs.html:6
msgid "Details"
msgstr ""
#: company/templates/company/tabs.html:9
msgid "Supplier Parts"
msgstr ""
#: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17
msgid "Stock"
msgstr ""
#: company/templates/company/tabs.html:15 part/templates/part/tabs.html:43
msgid "Purchase Orders"
msgstr ""
#: company/templates/company/tabs.html:21
msgid "Sales Orders"
msgstr ""
#: order/forms.py:21 #: order/forms.py:21
msgid "Place order" msgid "Place order"
msgstr "" msgstr ""
@ -923,18 +957,10 @@ msgstr ""
msgid "Part cannot be sold to customers" msgid "Part cannot be sold to customers"
msgstr "" msgstr ""
#: part/templates/part/notes.html:13 part/templates/part/notes.html:28 #: part/templates/part/notes.html:13 part/templates/part/notes.html:29
msgid "Part Notes" msgid "Part Notes"
msgstr "" msgstr ""
#: part/templates/part/notes.html:19
msgid "Save"
msgstr ""
#: part/templates/part/notes.html:31
msgid "Edit notes"
msgstr ""
#: part/templates/part/part_base.html:11 #: part/templates/part/part_base.html:11
msgid "This part is not active" msgid "This part is not active"
msgstr "" msgstr ""
@ -967,10 +993,6 @@ msgstr ""
msgid "Underway" msgid "Underway"
msgstr "" msgstr ""
#: part/templates/part/tabs.html:6
msgid "Details"
msgstr ""
#: part/templates/part/tabs.html:9 #: part/templates/part/tabs.html:9
msgid "Parameters" msgid "Parameters"
msgstr "" msgstr ""
@ -979,10 +1001,6 @@ msgstr ""
msgid "Variants" msgid "Variants"
msgstr "" msgstr ""
#: part/templates/part/tabs.html:17
msgid "Stock"
msgstr ""
#: part/templates/part/tabs.html:26 #: part/templates/part/tabs.html:26
msgid "BOM" msgid "BOM"
msgstr "" msgstr ""
@ -999,10 +1017,6 @@ msgstr ""
msgid "Suppliers" msgid "Suppliers"
msgstr "" msgstr ""
#: part/templates/part/tabs.html:43
msgid "Purchase Orders"
msgstr ""
#: part/templates/part/tabs.html:48 #: part/templates/part/tabs.html:48
msgid "Tracking" msgid "Tracking"
msgstr "" msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-01 12:31+0000\n" "POT-Creation-Date: 2020-02-01 12:45+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -357,7 +357,8 @@ msgstr ""
msgid "Supplier part description" msgid "Supplier part description"
msgstr "" msgstr ""
#: company/models.py:248 order/templates/order/purchase_order_detail.html:168 #: company/models.py:248 company/templates/company/tabs.html:26
#: order/templates/order/purchase_order_detail.html:168
#: part/templates/part/tabs.html:58 stock/templates/stock/item.html:151 #: part/templates/part/tabs.html:58 stock/templates/stock/item.html:151
msgid "Notes" msgid "Notes"
msgstr "" msgstr ""
@ -370,10 +371,43 @@ msgstr ""
msgid "Part packaging" msgid "Part packaging"
msgstr "" msgstr ""
#: company/templates/company/notes.html:10
#: company/templates/company/notes.html:27
msgid "Company Notes"
msgstr ""
#: company/templates/company/notes.html:17 part/templates/part/notes.html:20
msgid "Save"
msgstr ""
#: company/templates/company/notes.html:30 part/templates/part/notes.html:32
msgid "Edit notes"
msgstr ""
#: company/templates/company/partdelete.html:5 #: company/templates/company/partdelete.html:5
msgid "Are you sure you want to delete the following Supplier Parts?" msgid "Are you sure you want to delete the following Supplier Parts?"
msgstr "" msgstr ""
#: company/templates/company/tabs.html:5 part/templates/part/tabs.html:6
msgid "Details"
msgstr ""
#: company/templates/company/tabs.html:9
msgid "Supplier Parts"
msgstr ""
#: company/templates/company/tabs.html:12 part/templates/part/tabs.html:17
msgid "Stock"
msgstr ""
#: company/templates/company/tabs.html:15 part/templates/part/tabs.html:43
msgid "Purchase Orders"
msgstr ""
#: company/templates/company/tabs.html:21
msgid "Sales Orders"
msgstr ""
#: order/forms.py:21 #: order/forms.py:21
msgid "Place order" msgid "Place order"
msgstr "" msgstr ""
@ -923,18 +957,10 @@ msgstr ""
msgid "Part cannot be sold to customers" msgid "Part cannot be sold to customers"
msgstr "" msgstr ""
#: part/templates/part/notes.html:13 part/templates/part/notes.html:28 #: part/templates/part/notes.html:13 part/templates/part/notes.html:29
msgid "Part Notes" msgid "Part Notes"
msgstr "" msgstr ""
#: part/templates/part/notes.html:19
msgid "Save"
msgstr ""
#: part/templates/part/notes.html:31
msgid "Edit notes"
msgstr ""
#: part/templates/part/part_base.html:11 #: part/templates/part/part_base.html:11
msgid "This part is not active" msgid "This part is not active"
msgstr "" msgstr ""
@ -967,10 +993,6 @@ msgstr ""
msgid "Underway" msgid "Underway"
msgstr "" msgstr ""
#: part/templates/part/tabs.html:6
msgid "Details"
msgstr ""
#: part/templates/part/tabs.html:9 #: part/templates/part/tabs.html:9
msgid "Parameters" msgid "Parameters"
msgstr "" msgstr ""
@ -979,10 +1001,6 @@ msgstr ""
msgid "Variants" msgid "Variants"
msgstr "" msgstr ""
#: part/templates/part/tabs.html:17
msgid "Stock"
msgstr ""
#: part/templates/part/tabs.html:26 #: part/templates/part/tabs.html:26
msgid "BOM" msgid "BOM"
msgstr "" msgstr ""
@ -999,10 +1017,6 @@ msgstr ""
msgid "Suppliers" msgid "Suppliers"
msgstr "" msgstr ""
#: part/templates/part/tabs.html:43
msgid "Purchase Orders"
msgstr ""
#: part/templates/part/tabs.html:48 #: part/templates/part/tabs.html:48
msgid "Tracking" msgid "Tracking"
msgstr "" msgstr ""

View File

@ -11,6 +11,7 @@
{% if editing %} {% if editing %}
<h4>{% trans "Part Notes" %}</h4> <h4>{% trans "Part Notes" %}</h4>
<hr>
<form method='POST'> <form method='POST'>
{% csrf_token %} {% csrf_token %}
@ -31,6 +32,7 @@
<button title='{% trans "Edit notes" %}' class='btn btn-default btn-glyph float-right' id='edit-notes'><span class='glyphicon glyphicon-edit'></span></button> <button title='{% trans "Edit notes" %}' class='btn btn-default btn-glyph float-right' id='edit-notes'><span class='glyphicon glyphicon-edit'></span></button>
</div> </div>
</div> </div>
<hr>
<div class='panel panel-default'> <div class='panel panel-default'>
<div class='panel-content'> <div class='panel-content'>
{{ part.notes | markdownify }} {{ part.notes | markdownify }}