-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1062 from dotKom/dashboard
Dashboard inventory module
- Loading branch information
Showing
11 changed files
with
258 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
from django.conf.urls import patterns, url | ||
|
||
urlpatterns = patterns('apps.inventory.dashboard.views', | ||
url(r'^$', 'index', name='inventory'), | ||
url(r'^item/(?P<pk>\d+)/$', 'details', name='details'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
from django.contrib import messages | ||
from django.contrib.auth.decorators import login_required | ||
from django.core.exceptions import PermissionDenied | ||
from django.shortcuts import render, get_object_or_404 | ||
|
||
from guardian.decorators import permission_required | ||
|
||
from apps.dashboard.tools import has_access, get_base_context | ||
from apps.inventory.models import Item, Batch | ||
|
||
|
||
@login_required | ||
@permission_required('inventory.view_item', return_403=True) | ||
def index(request): | ||
|
||
# Generic check to see if user has access to dashboard. (In Komiteer or superuser) | ||
if not has_access(request): | ||
raise PermissionDenied | ||
|
||
# Create the base context needed for the sidebar | ||
context = get_base_context(request) | ||
|
||
context['items'] = Item.objects.all().order_by('name') | ||
|
||
return render(request, 'inventory/dashboard/index.html', context) | ||
|
||
|
||
@login_required | ||
@permission_required('inventory.change_item', return_403=True) | ||
def details(request, pk): | ||
# Generic check to see if user has access to dashboard. (In Komiteer or superuser) | ||
if not has_access(request): | ||
raise PermissionDenied | ||
|
||
# Create the base context needed for the sidebar | ||
context = get_base_context(request) | ||
|
||
context['item'] = get_object_or_404(Item, pk=pk) | ||
|
||
return render(request, 'inventory/dashboard/details.html', context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
The Company module exposes functionality needed in the company section | ||
of the dashboard. | ||
*/ | ||
|
||
var Inventory = (function ($, tools) { | ||
|
||
// Perform self check, display error if missing deps | ||
var performSelfCheck = function () { | ||
var errors = false | ||
if ($ == undefined) { | ||
console.error('jQuery missing!') | ||
errors = !errors | ||
} | ||
if (tools == undefined) { | ||
console.error('Dashboard tools missing!') | ||
errors = !errors | ||
} | ||
if (errors) return false | ||
return true | ||
} | ||
|
||
return { | ||
|
||
// Bind them buttons and other initial functionality here | ||
init: function () { | ||
|
||
if (!performSelfCheck()) return | ||
|
||
$('#inventory_item_list').tablesorter() | ||
|
||
} | ||
|
||
} | ||
|
||
})(jQuery, Dashboard.tools) | ||
|
||
$(document).ready(function () { | ||
Inventory.init() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{% extends "dashboard_base.html" %} | ||
{% load compress %} | ||
|
||
{% block title %} | ||
Varelager - Online Dashboard | ||
{% endblock title %} | ||
|
||
{% block styles %} | ||
{{ block.super }} | ||
{% compress css %} | ||
{% endcompress %} | ||
{% endblock %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
{% compress js %} | ||
<script src="{{ STATIC_URL }}js/dashboard/inventory.js"></script> | ||
{% endcompress %} | ||
{% endblock js %} | ||
|
||
{% block page-header %} | ||
Varelager | ||
{% endblock %} | ||
|
||
{% block breadcrumbs %} | ||
<li>Varelager</li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<h3>{{ item.name }}</h3> | ||
<table class="table table-striped table-condensed tablesorter" id="inventory_item_list"> | ||
<thead> | ||
<tr> | ||
<th>Mengde</th> | ||
<th>Utløpsdato</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for batch in item.batches.all %} | ||
<tr> | ||
<td>{{ batch.amount }}</td> | ||
<td>{{ batch.expiration_date|date:'Y-m-d' }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{% extends "dashboard_base.html" %} | ||
{% load compress %} | ||
|
||
{% block title %} | ||
Varelager - Online Dashboard | ||
{% endblock title %} | ||
|
||
{% block styles %} | ||
{{ block.super }} | ||
{% compress css %} | ||
{% endcompress %} | ||
{% endblock %} | ||
|
||
{% block js %} | ||
{{ block.super }} | ||
{% compress js %} | ||
<script src="{{ STATIC_URL }}js/dashboard/inventory.js"></script> | ||
{% endcompress %} | ||
{% endblock js %} | ||
|
||
{% block page-header %} | ||
Varelager | ||
{% endblock %} | ||
|
||
{% block breadcrumbs %} | ||
<li>Varelager</li> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<a href="#" class="btn btn-primary"><i class="fa fa-plus"></i> Legg til vare</a> | ||
</div> | ||
</div> | ||
<br /> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Vareoversikt</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p>Her finner du en oversikt over varelageret. Alle oppføringer vil ha en eller flere mengder av varen tilknyttet seg, slik at man kan skille på utløpsdatoer i batch.</p> | ||
<table class="table table-striped table-condensed tablesorter" id="inventory_item_list"> | ||
<thead> | ||
<tr> | ||
<th>Navn</th> | ||
<th>Mengde</th> | ||
<th>Eldste utløpsdato</th> | ||
<th>Nyeste oppføring</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for item in items %} | ||
<tr> | ||
<td><a href="/dashboard/inventory/item/{{ item.id }}/">{{ item.name }}</a></td> | ||
<td>{{ item.total_amount }}</td> | ||
<td {% if item.has_expired_batch %}class="red"{% endif %}> | ||
{{ item.oldest_expiration_date|date:'Y-m-d' }} | ||
</td> | ||
<td>{{ item.last_added|date:'Y-m-d' }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |