Skip to content

Commit f64610b

Browse files
authored
Merge pull request #8 from ChaosRambo/master
Add item description to item's page
2 parents 09c5820 + e9bf74b commit f64610b

8 files changed

Lines changed: 142 additions & 3 deletions

File tree

README.md

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,93 @@
11
# python3-django-inventory
22
An inventory management system, based on buckets you can place items in
33

4-
# Installation
5-
This is a python 3 django module and cannot be used standalone. Also needs `crispy_forms`, which on debianoid systems is available as `python3-django-crispy-forms`. Create a project, add the contents of this repositories as a directory named `inventory`.
4+
# Install Guide
5+
**Requirements (Global Installations)**
6+
- Python3
7+
- NGINX
8+
- python3-django
9+
- python3-django-crispy-forms
10+
- uwsgi
11+
- uwsgi-plugin-python3
12+
13+
**Install Steps**
14+
15+
**Django**
16+
1. Create a new User and login as User
17+
- `adduser inventory`*
18+
- `su - inventory`*
19+
2. Create Django-Project
20+
- `django-admin startproject website`*
21+
- `cd website`*
22+
3. Get python3-django-inventory
23+
- `git clone https://github.com/ChaosRambo/python3-django-inventory.git inventory`
24+
4. Configure Django
25+
- `vim website/settings.py`*
26+
- Add to `INSTALLED_APPS`:
27+
- `'inventory',`
28+
- `'crispy_forms',`
29+
- Add to the end of the Settings:
30+
- STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
31+
5. Migrate
32+
- `./manage.py --migrate`
33+
6. Optional Step
34+
- Test Django
35+
- `./manage.py --runserver`
36+
- You will see the Django Test site
37+
- ![enter image description here](https://github.com/ChaosRambo/python3-django-inventory/blob/master/screenshots/django_testpage.jpeg?raw=true)
38+
7. Add URL Config
39+
- `vim website/urls.py`
40+
- Add if not exists:
41+
- `from django.conf.urls import url, include`
42+
- Add in `urlpatterns`
43+
- `url(r'^', include('inventory.urls', namespace='inventory')),`
44+
8. Collectstatics
45+
- `./manage.py --collectstatics`
46+
9. Optional Step
47+
- Test Django
48+
- `./manage.py runserver`
49+
- You will see an empty inventory
50+
- ![enter image description here](https://github.com/ChaosRambo/python3-django-inventory/blob/master/screenshots/empty_inventory.jpeg?raw=true)
51+
10. Add Admin
52+
- `./manage.py createsuperuser`
53+
11. Close User
54+
- `exit`
55+
56+
**uWSGI**
57+
58+
1. Optional Step - Try if uWSGI correct work
59+
- `uwsgi --master --http :5000 --chdir /home/inventory/website --module website.wsgi:application`
60+
- Don't worry, if you open the site in your browser, you won't see any static stuff
61+
2. Write Systemd Service
62+
- Download the Service file with the following line:
63+
- `wget https://raw.githubusercontent.com/ChaosRambo/python3-django-inventory/master/documents/uwsgi.service -P /etc/systemd/system`
64+
- Optional: DIY
65+
- Write your own `uwsgi.service` in
66+
- `/etc/systemd/system/`
67+
- You will find more examples here:
68+
- http://uwsgi-docs.readthedocs.io/en/latest/Systemd.html
69+
3. Write uWSGI config
70+
- Create folder `sites` in:
71+
- `/etc/uwsgi`
72+
- Download inventory.ini:
73+
- `wget https://raw.githubusercontent.com/ChaosRambo/python3-django-inventory/master/documents/inventory.ini -P /etc/uwsgi/sites`
74+
- Optional: DIY
75+
- Write your own config in `sites`
76+
- You will find more examples here:
77+
- http://uwsgi-docs.readthedocs.io/en/latest/Configuration.html
78+
4. Systemd
79+
- `systemctl enable uwsgi.service`
80+
- `systemctl start uwsgi.service`
81+
82+
**NGINX**
83+
84+
1. Write NGINX Config
85+
- Download this config
86+
- `wget https://raw.githubusercontent.com/ChaosRambo/python3-django-inventory/master/documents/nginxconf -O inventory -P /etc/nginx/sites-available`
87+
- `ln -s /etc/nginx/sites-available/inventory /etc/nginx/sites-enabled/`
88+
- Optional: DIY
89+
- Write your Own Nginx config and create a Softlink to `sites-enabled`
90+
- Yor will find more examples here:
91+
- http://nginx.org/en/docs/
92+
93+

documents/inventory.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[uwsgi]
2+
uid = inventory
3+
gid = www-data
4+
base = /home/%(uid)
5+
6+
chdir = %(base)/website
7+
module = page.wsgi:application
8+
9+
master = true
10+
processes = 5
11+
12+
socket = /run/uwsgi/inventory.sock
13+
chown-socket = %(uid):www-data
14+
chmod-socket = 660
15+
vacuum = true
16+
17+
plugin = python3

documents/nginxconf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
server {
2+
listen 8080;
3+
location /static/ {
4+
root /home/inventory/website;
5+
}
6+
location / {
7+
include uwsgi_params;
8+
uwsgi_modifier1 0;
9+
uwsgi_pass unix:/run/uwsgi/inventory.sock;
10+
}
11+
}
12+

documents/uwsgi.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=uWSGI Emperor
3+
4+
[Service]
5+
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown inventory:www-data /run/uwsgi'
6+
ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites/inventory.ini --enable-threads
7+
Restart=always
8+
KillSignal=SIGQUIT
9+
Type=notify
10+
StandardError=syslog
11+
NotifyAccess=all
12+
13+
[Install]
14+
WantedBy=multi-user.target

screenshots/django_testpage.jpeg

61.4 KB
Loading

screenshots/empty_inventory.jpeg

31.5 KB
Loading

templates/inventory/item.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<div class="card">
22
<div class="card-block"><h4 class="card-title">{{ i.name }}</h4>
3+
<table class="table table-sm">
4+
<thead><tr><th colspan="2">Description</th></tr></thead>
5+
<tbody>
6+
<tr>
7+
<td>{{ i.desc }}</td>
8+
</tr>
9+
</tbody>
10+
</table>
311
{% if i.identifier_set.exists or bucket_as_property %}
412
<table class="table table-sm">
513
<thead><tr><th colspan="2">Properties</th></tr></thead>

views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def add(request, bucket_id=None):
9494
identifier.save()
9595
else:
9696
context = {
97-
'error_text': 'Invalid Identifier: ' + identifier.errors.as_json()
97+
'error_text': 'Invalid Identifier: ' + identifier.errors.as_json(escape_html=False)
9898
}
9999
return render(request, 'inventory/error.html', context)
100100

0 commit comments

Comments
 (0)