Permalink
Browse files

importing original sources

  • Loading branch information...
1 parent c2e6dcb commit 18f4f303806fe2e14aae6998c5114a93a1c54e88 @robottrouble robottrouble committed Sep 13, 2010
Showing 1,239 changed files with 1,779 additions and 0 deletions.
View
@@ -0,0 +1 @@
+*.pyc
View
No changes.
View
No changes.
View
@@ -0,0 +1,27 @@
+from hive76_inventory.inventory.models import *
+from django.forms import ModelForm
+
+class PartsForm(ModelForm):
+ class Meta:
+ model = Parts
+ exclude = ('cross_reference','created_by','modified_by')
+
+class PartAttachmentsForm(ModelForm):
+ class Meta:
+ model = PartAttachments
+
+class StockForm(ModelForm):
+ class Meta:
+ model = Stock
+
+class LocationsForm(ModelForm):
+ class Meta:
+ model = Locations
+
+class VendorsForm(ModelForm):
+ class Meta:
+ model = Vendors
+
+class PartVendorsForm(ModelForm):
+ class Meta:
+ model = PartVendors
View
@@ -0,0 +1,112 @@
+from django.db import models
+from django import template
+from django.contrib.auth.models import User
+import locale, os
+
+locale.setlocale(locale.LC_ALL, '')
+
+# Create your models here.
+
+class Parts(models.Model):
+ name = models.CharField(max_length=128)
+ description = models.CharField(max_length = 1024)
+ minimum_stock = models.PositiveIntegerField(default = 0)
+ cross_reference = models.ManyToManyField("self")
+ photo = models.ImageField(upload_to='images/parts_photos', blank=True, null=True)
+ thumbnail = models.ImageField(upload_to='images/parts_thumbnails', blank=True, null=True, editable=False)
+ created_by = models.ForeignKey(User, null=False, blank=False, related_name='created_parts')
+ modified_by = models.ForeignKey(User, null=False, blank=False, related_name='modified_parts')
+ TYPE_CHOICES = (
+ ('P', 'Part'),
+ ('T', 'Tool')
+ )
+ type = models.CharField(max_length = 1, null=False, blank=False, choices=TYPE_CHOICES)
+
+ def __unicode__(self):
+ return self.name
+
+ def get_reorder_count(self):
+ return self.minimum_stock - self.stock.count()
+
+ def get_reorder_items(self):
+ # FIXME - There's gotta be a better way...
+ p = Parts.objects.filter(minimum_stock__gt=0)
+
+ for part in p:
+ if part.stock.select_related().count() >= part.minimum_stock:
+ print part
+ p = p.exclude(pk=part.id)
+ return p
+
+ class Admin:
+ pass
+
+class PartAttachments(models.Model):
+ part = models.ForeignKey(Parts, related_name="attachments", null=False)
+ file = models.FileField(upload_to='attachments/part_attachments/', null=False)
+ preview = models.ImageField(upload_to='attachments/part_attachments/previews', null=True, blank=True)
+
+ def get_preview(self):
+ return self.file
+
+ def basename(self):
+ return os.path.basename(self.file.name)
+
+class Locations(models.Model):
+ name = models.CharField(max_length = 128, unique=True)
+ description = models.CharField(max_length = 1024)
+
+ def __unicode__(self):
+ return self.name
+
+class Stock(models.Model):
+ type = models.ForeignKey(Parts, related_name="stock")
+ location = models.ForeignKey(Locations, related_name="stock")
+ serial_number = models.CharField(max_length = 128, blank=True)
+ def __unicode__(self):
+ return self.type.name
+
+class PartComponents(models.Model):
+ parent_part = models.ForeignKey(Parts, related_name="components")
+ child_part = models.ForeignKey(Parts, related_name="parent_parts")
+ quantity = models.PositiveIntegerField(default = 1)
+
+ def __str__(self):
+ return self.child_part.type.name
+
+class Vendors(models.Model):
+ name = models.CharField(max_length = 128, unique=True)
+ URL = models.CharField(max_length = 1024, blank=True)
+ phone = models.CharField(max_length = 10, blank=True)
+ fax = models.CharField(max_length = 10, blank=True)
+
+ def __str__(self):
+ return self.name
+
+class PartVendors(models.Model):
+ part = models.ForeignKey(Parts,related_name='vendors')
+ vendor= models.ForeignKey(Vendors,related_name='parts')
+ part_number = models.CharField(max_length=2048, blank=True)
+ URL = models.CharField(max_length=2048, blank=True)
+ cost = models.DecimalField(max_digits=10, decimal_places=2, null=True)
+ minimum_order = models.PositiveIntegerField(default = 1, null=True)
+
+ def cost_as_currency(self):
+ locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
+ costAsCurrency = locale.currency(self.cost)
+ return costAsCurrency
+
+ def __str__(self):
+ return self.part.name + " - " + self.vendor.name
+
+# class Users(models.Model):
+# user_name = models.CharField(max_length = 20)
+# real_name = models.CharField(max_length = 128)
+# email = models.CharField(max_length = 128)
+
+class Comments(models.Model):
+ part = models.ForeignKey(Parts, related_name='comments', null=True,blank=True)
+ stock_item = models.ForeignKey(Stock, related_name='comments',null=True,blank=True)
+ text = models.CharField(max_length = 1024)
+ author = models.ForeignKey(User)
+ date = models.DateTimeField(auto_now_add=True)
@@ -0,0 +1,9 @@
+<html>
+<body>
+Welcome! Not much here yet...
+<br>
+Have a look at <a href="/parts/">Parts</a> and <a href="/vendors/">Vendors</a>.
+
+
+</body>
+</html>
@@ -0,0 +1,34 @@
+<html>
+<head>
+<title>{% block title %}{% endblock %}</title>
+<link href="/media/css/style.css" media="screen" rel="stylesheet" type="text/css" />
+</head>
+<body>
+<table width='75%' align="center" border="0" cellspacing="0" cellpadding="10">
+ <tr>
+ <td>Hiventory76</td>
+ <td class="header" align="right">
+ <a href="/parts/">Parts</a>
+ | <a href="/stock/">Stock</a>
+ | <a href="/vendors/">Vendors</a>
+ | <a href="/locations/">Locations</a>
+ | <a href="/reports/">Reports</a>
+ </td>
+ </tr>
+ <tr>
+ <td align="left" class="header">
+ {% if user.is_authenticated %}
+ Logged in as {{ user }} | <a href="/accounts/logout/">Log-Out</a>
+ {% else %}
+ Sign Up or <a href="/accounts/login/?next={{request.path}}">Log-In</a>
+ {% endif %}
+ </td>
+ <td align="right" colspan="2"><form name="frmMasterSearch" action="/parts/" method="POST">Search: <input type="text" name="txtMasterPartSearch"><input type="Submit" name="Submit" value="Search"></form></td>
+ </tr>
+</table>
+<br>
+<br>
+<br>
+{% block content %}{% endblock %}
+</body>
+</html>
@@ -0,0 +1,12 @@
+{% extends 'layout.html' %}
+
+{% block title %}Add Location: {{ part.id }}{% endblock%}
+
+{% block content %}
+<form method="POST" action="">
+<table align="center">
+{{ form.as_table }}
+ <tr><td colspan="2" align="right"><input type="submit" name="Submit" value="Submit"><input type="submit" name="Cancel" value="Cancel"></td></tr>
+</table>
+</form>
+{% endblock %}
@@ -0,0 +1,12 @@
+{% extends 'layout.html' %}
+
+{% block title %}Add Location: {{ part.id }}{% endblock%}
+
+{% block content %}
+<form method="POST" action="">
+<table align="center">
+{{ form.as_table }}
+ <tr><td colspan="2" align="right"><input type="submit" name="Submit" value="Submit"><input type="submit" name="Cancel" value="Cancel"></td></tr>
+</table>
+</form>
+{% endblock %}
@@ -0,0 +1,16 @@
+{% extends 'layout.html' %}
+
+{% block title %}View Part{% endblock%}
+
+{% block content %}
+<table align="center">
+ <tr>
+ <th align="left">Name:</th>
+ <td>{{ location.name }}</td>
+ </tr>
+ <tr>
+ <th align="left">Description:</th>
+ <td>{{ location.description }}</td>
+ </tr>
+</table>
+{% endblock %}
@@ -0,0 +1,62 @@
+{% extends 'layout.html' %}
+
+{% block title %}View All Locations{% endblock%}
+
+{% block content %}
+
+
+
+<div class="pagination" align="center">
+<span class="step-links">
+{% if locations.has_previous %}
+<a href="?page={{ locations.previous_page_number }}">previous</a>
+{% endif %}
+
+<span class="current">
+Page {{ locations.number }} of {{ locations.paginator.num_pages }}.
+</span>
+
+{% if locations.has_next %}
+<a href="?page={{ locations.next_page_number }}">next</a>
+{% endif %}
+</span>
+</div>
+<p />
+<p />
+<table align=center border=0>
+<tr>
+
+ <th colspan=3>Locations</th>
+</tr>
+<tr>
+ <th>Name</th><th>Description</th><th>&nbsp;</th>
+<tr>
+{% for loc in locations.object_list %}
+ <tr bgcolor="#{% cycle "C0C0C0" "FFFFFF" %}">
+ <td><a href="/locations/view/{{ loc.id }}/">{{ loc.name }}</a></td>
+ <td>{{ loc.description }}</td>
+ <td><a href="/locations/edit/{{ loc.id }}/">Edit</a></td>
+ </tr>
+{% endfor %}
+<tr>
+ <td colspan=3 align="right"><a href="/locations/new">Add New Location</a></td>
+</tr>
+</table>
+<p />
+<div class="pagination" align="center">
+<span class="step-links">
+{% if locations.has_previous %}
+<a href="?page={{ locations.previous_page_number }}">previous</a>
+{% endif %}
+
+<span class="current">
+Page {{ locations.number }} of {{ locations.paginator.num_pages }}.
+</span>
+
+{% if locations.has_next %}
+<a href="?page={{ locations.next_page_number }}">next</a>
+{% endif %}
+</span>
+</div>
+
+{% endblock %}
@@ -0,0 +1,25 @@
+{% extends "layout.html" %}
+
+{% block content %}
+
+{% if form.errors %}
+<p>Your username and password didn't match. Please try again.</p>
+{% endif %}
+<form method="post" action="/accounts/login/">
+<table>
+<tr>
+<td>{{ form.username.label_tag }}</td>
+<td>{{ form.username }}</td>
+</tr>
+<tr>
+<td>{{ form.password.label_tag }}</td>
+<td>{{ form.password }}</td>
+</tr>
+</table>
+
+<input type="submit" value="login" />
+<input type="hidden" name="next" value="{{ next }}" />
+</form>
+
+{% endblock %}
+
Oops, something went wrong.

0 comments on commit 18f4f30

Please sign in to comment.