Merge remote-tracking branch 'inventree/master'

This commit is contained in:
Oliver Walters 2019-05-04 11:49:49 +10:00
commit a7cec1627f
9 changed files with 112 additions and 23 deletions

View File

@ -0,0 +1,19 @@
""" Version information for InvenTree.
Provides information on the current InvenTree version
"""
import subprocess
INVENTREE_SW_VERSION = "0.0.1"
def inventreeVersion():
""" Returns the InvenTree version string """
return INVENTREE_SW_VERSION
def inventreeCommitHash():
""" Returns the git commit hash for the running codebase """
commit = str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip()
return commit

View File

@ -298,9 +298,6 @@ class IndexView(TemplateView):
# Generate a list of buildable parts which have stock below their minimum values # Generate a list of buildable parts which have stock below their minimum values
context['to_build'] = [part for part in Part.objects.filter(buildable=True) if part.need_to_restock()] context['to_build'] = [part for part in Part.objects.filter(buildable=True) if part.need_to_restock()]
print("order:", len(context['to_order']))
print("build:", len(context['to_build']))
return context return context

View File

@ -1,12 +0,0 @@
""" This module provides template tags for extra functionality
over and above the built-in Django tags.
"""
from django import template
register = template.Library()
@register.simple_tag()
def multiply(x, y, *args, **kwargs):
return x * y

View File

@ -143,7 +143,6 @@ class BuildComplete(AjaxUpdateView):
location = StockLocation.objects.get(id=loc_id) location = StockLocation.objects.get(id=loc_id)
valid = True valid = True
except StockLocation.DoesNotExist: except StockLocation.DoesNotExist:
print('id:', loc_id)
form.errors['location'] = ['Invalid location selected'] form.errors['location'] = ['Invalid location selected']
if valid: if valid:

View File

@ -0,0 +1,32 @@
""" This module provides template tags for extra functionality
over and above the built-in Django tags.
"""
from django import template
from InvenTree import version
register = template.Library()
@register.simple_tag()
def multiply(x, y, *args, **kwargs):
""" Multiply two numbers together """
return x * y
@register.simple_tag()
def inventree_version(*args, **kwargs):
""" Return InvenTree version string """
return version.inventreeVersion()
@register.simple_tag()
def inventree_commit(*args, **kwargs):
""" Return InvenTree git commit hash string """
return version.inventreeCommitHash()
@register.simple_tag()
def inventree_github(*args, **kwargs):
""" Return URL for InvenTree github site """
return "https://github.com/InvenTree"

View File

@ -0,0 +1,40 @@
{% load static %}
{% load inventree_extras %}
<div class='modal fade modal-fixed-footer' tabindex='-1' role='dialog' id='modal-about'>
<div class='modal-dialog'>
<div class='modal-content'>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<img src="{% static 'img/inventree.png' %}" height='60' style='float: left;' alt='Inventree Logo'>
</div>
<div class='modal-form-content'>
<div>
<!--
-->
<h4>InvenTree Version Information</h4>
<table class='table table-striped table-condensed'>
<tr>
<td>Version</td><td>{% inventree_version %}</td>
</tr>
<tr>
<td>Commit Hash</td><td>{% inventree_commit %}</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td>View Code on GitHub</td><td><a href="{% inventree_github %}">{% inventree_github %}</a></td>
</tr>
</table>
</div>
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
</div>
</div>
</div>
</div>

View File

@ -49,6 +49,7 @@ InvenTree
</div> </div>
{% include 'modals.html' %} {% include 'modals.html' %}
{% include 'about.html' %}
{% include 'notification.html' %} {% include 'notification.html' %}
</div> </div>
@ -76,6 +77,17 @@ $(document).ready(function () {
{% block js_ready %} {% block js_ready %}
{% endblock %} {% endblock %}
showCachedAlerts(); showCachedAlerts();
$('#launch-about').click(function() {
var modal = $('#modal-about');
modal.modal({
backdrop: 'static',
keyboard: 'false',
});
modal.modal('show');
});
}); });
</script> </script>

View File

@ -13,19 +13,21 @@
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
{% include "search_form.html" %} {% include "search_form.html" %}
{% if user.is_authenticated %}
<li class='dropdown'> <li class='dropdown'>
<a class='dropdown-toggle' data-toggle='dropdown' href="#"><span class="glyphicon glyphicon-user"></span> <b>{{ user.get_username }}</b></a> <a class='dropdown-toggle' data-toggle='dropdown' href="#"><span class="glyphicon glyphicon-user"></span> <b>{{ user.get_username }}</b></a>
<ul class='dropdown-menu'> <ul class='dropdown-menu'>
{% if user.is_authenticated %}
{% if user.is_staff %} {% if user.is_staff %}
<li><a href="/admin/"><span class="glyphicon glyphicon-edit"></span> Admin</a></li> <li><a href="/admin/"><span class="glyphicon glyphicon-edit"></span> Admin</a></li>
{% endif %} {% endif %}
<li><a href="{% url 'logout' %}"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li> <li><a href="{% url 'logout' %}"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
</ul>
</li>
{% else %} {% else %}
<li><a href="{% url 'login' %}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li> <li><a href="{% url 'login' %}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
{% endif %} {% endif %}
<hr>
<li id='launch-about'><a href='#'>About InvenTree</a></li>
</ul>
</li>
</ul> </ul>
</div> </div>
</nav> </nav>