- ##### Imports #####
- from django.db import models
- from django.contrib import admin
- ##### Status Model ######
- class Status(models.Model):
- """
- This class is used to isolate the need for 1000+ references to
- Status from various tables
- Usage:
- #Make a new object
- statusToAdd = Status()
- #to give it an ID
- statusToAdd.description = x
- #Write it to the DB
- statusToAdd.save()
- #Get one by the PK / ID with PK/ID == 1
- statusToMessWith = Status.objects.get(pk=1)
- ..do some changes...
- Save it to the db with
- statusToMessWith.save()
- """
- description = models.CharField(max_length=30)
- def __unicode__(self):
- return str(self.description)
- class StatusAdmin(admin.ModelAdmin):
- list_display = ('id', 'description')
- search_fields = ('id', 'description')
- #Register it with the Admin Interface
- admin.site.register(Status, StatusAdmin)
- ##### Manufacturer Model ######
- class Manufacturer(models.Model):
- """
- This class defines the roles and properties of the Manufacturer table
- It is based off of the manufacters table found inside pdfsupply.com's
- PHP / MYSQL site.
- Usage:
- #Make a new object
- manufacturerToAdd = Manufacturer()
- #to give it an ID
- manufacturerToAdd.id = x
- #Write it to the DB
- manufacturerToAdd.save()
- #Get one by the PK / ID with PK/ID == 1
- manufacturerToMessWith = Manufacturer.objects.get(pk=1)
- ..do some changes...
- Save it to the db with
- manufacturerToMessWith.save()
- """
- id = models.IntegerField(primary_key=True)
- name = models.CharField(max_length=200, null=True, blank=True)
- page_name = models.CharField(max_length=50, null=True, blank=True)
- address = models.CharField(max_length=200, null=True, blank=True)
- zip = models.CharField(max_length=20, null=True, blank=True)
- phone = models.CharField(max_length=20, null=True, blank=True)
- fax = models.CharField(max_length=20, null=True, blank=True)
- title_tag = models.CharField(max_length=250, null=True, blank=True)
- description_tag = models.TextField(null=True, blank=True)
- keywords_Tag = models.TextField(null=True, blank=True)
- contact_name = models.CharField(max_length=50, null=True, blank=True)
- contact_email = models.EmailField(null=True, blank=True)
- contact_phone = models.CharField(max_length=20, null=True, blank=True)
- about = models.TextField(null=True, blank=True)
- website = models.CharField(max_length=150, null=True, blank=True)
- #Not sure if I should Add logo like this
- #logo = models.CharField(max_length=50, null=True, blank=True)
- lead_time = models.CharField(max_length=100, null=True, blank=True)
- priority = models.IntegerField(null=True, blank=True)
- status = models.ForeignKey(Status, unique=False)
- def __unicode__self(self):
- """
- This function is called when django wishes to show your object,
- we need a way of rendering its contents by default, all other
- parameters are still accessible.
- """
- return str(self.name)
- class ManufacturerAdmin(admin.ModelAdmin):
- """
- This class is used by the admin interface to determine what fields are shown
- when you look at an item in the list view, inside the admin panel.
- It also defines the valid search fields using the default search engine
- in Django
- """
- list_display = ('id','name','website','status')
- search_fields = ('id','name','website','status')
- #Register it with the Admin Interface
- admin.site.register(Manufacturer, ManufacturerAdmin)
- ##### Series Model ######
- class Series(models.Model):
- """
- This class defines the roles and properties of the Series table
- It is based off of the Series table found inside pdfsupply.com's
- PHP / MYSQL site.
- Usage:
- #Make a new object
- seriesToAdd = Series()
- #to give it an ID
- seriesToAdd.id = x
- #Write it to the DB
- seriesToAdd.save()
- #Get one by the PK / ID with PK/ID == 1
- seriesMessWith = Series.objects.get(pk=1)
- ..do some changes...
- Save it to the db with
- seriesMessWith.save()
- """
- id = models.IntegerField(primary_key=True)
- manufacturer_ID = models.ForeignKey(Manufacturer, unique=False)
- name = models.CharField(max_length=50, null=True, blank=True)
- page_name = models.CharField(max_length=100, null=True, blank=True)
- description = models.TextField(null=True, blank=True)
- image = models.ImageField(upload_to="imgs/", null=True, blank=True)
- title_tag = models.CharField(max_length=250, null=True, blank=True)
- description_tag = models.TextField(null=True, blank=True)
- keywords_tag = models.TextField(null=True, blank=True)
- #This will need to be changed
- status = models.ForeignKey(Status, unique=False)
- def __unicode__(self):
- return str(self.name)
- class SeriesAdmin(admin.ModelAdmin):
- """
- This class is used by the admin interface to determine what fields are shown
- when you look at an item in the list view, inside the admin panel.
- It also defines the valid search fields using the default search engine
- in Django
- """
- list_display = ('id', 'manufacturer_ID', 'name', 'status')
- search_fields = ('id', 'manufacturer_ID', 'name', 'status')
- #Register it with the Admin Interface
- admin.site.register(Series, SeriesAdmin)
- ##### Product Model ######
- class Product(models.Model):
- """
- This class defines the roles and properties of the Product table
- It is based off of the Product table found inside pdfsupply.com's
- PHP / MYSQL site.
- Usage:
- #Make a new object
- productToAdd = Product()
- #to give it an ID
- productToAdd.id = x
- #Write it to the DB
- productToAdd.save()
- #Get one by the PK / ID with PK/ID == 1
- productToMessWith = Product.objects.get(pk=1)
- ..do some changes...
- Save it to the db with
- productToMessWith.save()
- """
- id = models.IntegerField(primary_key=True)
- series_ID = models.ForeignKey(Series, unique=False)
- part_number = models.CharField(max_length=20, null=True, blank=True)
- description = models.TextField(null=True, blank=True)
- title_tag = models.CharField(max_length=250, null=True, blank=True)
- description_tag = models.TextField(null=True, blank=True)
- keywords_tag = models.TextField(null=True, blank=True)
- typos = models.TextField(null=True, blank=True)
- featured = models.IntegerField(null=True, blank=True)
- remanufactured_inventory = models.IntegerField(null=True, blank=True)
- remanufactured_price = models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True)
- new_inventory = models.IntegerField(null=True, blank=True)
- new_price = models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True)
- stock_level = models.CharField(max_length=30, null=True, blank=True)
- repair_time = models.CharField(max_length=30, null=True, blank=True)
- youtube_link = models.CharField(max_length=20, null=True, blank=True)
- condition = models.CharField(max_length=30, null=True, blank=True)
- show_revision_links = models.IntegerField(null=True, blank=True)
- group_tag = models.CharField(max_length=20, null=True, blank=True)
- status = models.ForeignKey(Status, unique=False)
- def __unicode__(self):
- return str(self.part_number)
- class ProductAdmin(admin.ModelAdmin):
- """
- This class is used by the admin interface to determine what fields are shown
- when you look at an item in the list view, inside the admin panel.
- It also defines the valid search fields using the default search engine
- in Django
- """
- list_display = ('id', 'series_ID', 'part_number', 'status')
- search_fields = ('id', 'series_ID', 'part_number', 'status')
- #Register it with the Admin Interface
- admin.site.register(Product, ProductAdmin)
- ##### Revision Model ######
- class Revision(models.Model):
- """
- This class defines the roles and properties of the Product table
- It is based off of the Product table found inside pdfsupply.com's
- PHP / MYSQL site.
- Usage:
- #Make a new object
- revisionToAdd = Revision()
- #to give it an ID
- revisionToAdd.id = x
- #Write it to the DB
- revisionToAdd.save()
- #Get one by the PK / ID with PK/ID == 1
- revisionToMessWith = Revision.objects.get(pk=1)
- ..do some changes...
- Save it to the db with
- revisionToMessWith.save()
- """
- id = models.IntegerField(primary_key=True)
- description = models.TextField(null=True, blank=True)
- title_tag = models.CharField(max_length=250, null=True, blank=True)
- description_tag = models.TextField(null=True, blank=True)
- keywords_tag = models.TextField(null=True, blank=True)
- group_tag = models.CharField(max_length=30, null=True, blank=True)
- status = models.ForeignKey(Status, unique=False)
- def __unicode__(self):
- return str(self.id)
- class RevisionAdmin(admin.ModelAdmin):
- """
- This class is used by the admin interface to determine what fields are shown
- when you look at an item in the list view, inside the admin panel.
- It also defines the valid search fields using the default search engine
- in Django
- """
- list_display = ('id', 'description', 'status')
- search_fields = ('id', 'description', 'status')
- #Register it with the Admin Interface
- admin.site.register(Revision, RevisionAdmin)