Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 3rd, 2012  |  syntax: None  |  size: 9.43 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ##### Imports #####
  2. from django.db import models
  3. from django.contrib import admin
  4.  
  5. ##### Status Model ######
  6. class Status(models.Model):
  7.     """
  8.     This class is used to isolate the need for 1000+ references to
  9.     Status from various tables
  10.  
  11.     Usage:
  12.     #Make a new object
  13.     statusToAdd = Status()
  14.  
  15.     #to give it an ID
  16.     statusToAdd.description = x
  17.  
  18.     #Write it to the DB
  19.     statusToAdd.save()
  20.  
  21.     #Get one by the PK / ID with PK/ID == 1
  22.     statusToMessWith = Status.objects.get(pk=1)
  23.     ..do some changes...
  24.     Save it to the db with
  25.     statusToMessWith.save()
  26.     """
  27.     description = models.CharField(max_length=30)
  28.  
  29.     def __unicode__(self):
  30.         return str(self.description)
  31.  
  32. class StatusAdmin(admin.ModelAdmin):
  33.     list_display = ('id', 'description')
  34.     search_fields = ('id', 'description')
  35.  
  36. #Register it with the Admin Interface
  37. admin.site.register(Status, StatusAdmin)
  38.  
  39.  
  40. ##### Manufacturer Model ######
  41. class Manufacturer(models.Model):
  42.     """
  43.     This class defines the roles and properties of the Manufacturer table
  44.     It is based off of the manufacters table found inside pdfsupply.com's
  45.     PHP / MYSQL site.
  46.  
  47.     Usage:
  48.     #Make a new object
  49.     manufacturerToAdd = Manufacturer()
  50.  
  51.     #to give it an ID
  52.     manufacturerToAdd.id = x
  53.  
  54.     #Write it to the DB
  55.     manufacturerToAdd.save()
  56.  
  57.     #Get one by the PK / ID with PK/ID == 1
  58.     manufacturerToMessWith = Manufacturer.objects.get(pk=1)
  59.     ..do some changes...
  60.     Save it to the db with
  61.     manufacturerToMessWith.save()
  62.     """
  63.     id = models.IntegerField(primary_key=True)
  64.     name = models.CharField(max_length=200, null=True, blank=True)
  65.     page_name = models.CharField(max_length=50, null=True, blank=True)
  66.     address = models.CharField(max_length=200, null=True, blank=True)
  67.     zip = models.CharField(max_length=20, null=True, blank=True)
  68.     phone = models.CharField(max_length=20, null=True, blank=True)
  69.     fax = models.CharField(max_length=20, null=True, blank=True)
  70.     title_tag = models.CharField(max_length=250, null=True, blank=True)
  71.     description_tag = models.TextField(null=True, blank=True)
  72.     keywords_Tag = models.TextField(null=True, blank=True)
  73.  
  74.     contact_name = models.CharField(max_length=50, null=True, blank=True)
  75.     contact_email = models.EmailField(null=True, blank=True)
  76.     contact_phone = models.CharField(max_length=20, null=True, blank=True)
  77.     about = models.TextField(null=True, blank=True)
  78.     website = models.CharField(max_length=150, null=True, blank=True)
  79.  
  80.     #Not sure if I should Add logo like this
  81.     #logo = models.CharField(max_length=50, null=True, blank=True)
  82.     lead_time = models.CharField(max_length=100, null=True, blank=True)
  83.     priority = models.IntegerField(null=True, blank=True)
  84.     status = models.ForeignKey(Status, unique=False)
  85.  
  86.     def __unicode__self(self):
  87.         """
  88.         This function is called when django wishes to show your object,
  89.         we need a way of rendering its contents by default, all other
  90.         parameters are still accessible.
  91.         """
  92.         return str(self.name)
  93.  
  94. class ManufacturerAdmin(admin.ModelAdmin):
  95.     """
  96.     This class is used by the admin interface to determine what fields are shown
  97.     when you look at an item in the list view, inside the admin panel.
  98.     It also defines the valid search fields using the default search engine
  99.     in Django
  100.     """
  101.     list_display = ('id','name','website','status')
  102.     search_fields = ('id','name','website','status')
  103.  
  104. #Register it with the Admin Interface
  105. admin.site.register(Manufacturer, ManufacturerAdmin)
  106.  
  107. ##### Series Model ######
  108. class Series(models.Model):
  109.     """
  110.     This class defines the roles and properties of the Series table
  111.     It is based off of the Series table found inside pdfsupply.com's
  112.     PHP / MYSQL site.
  113.  
  114.     Usage:
  115.     #Make a new object
  116.     seriesToAdd = Series()
  117.  
  118.     #to give it an ID
  119.     seriesToAdd.id = x
  120.  
  121.     #Write it to the DB
  122.     seriesToAdd.save()
  123.  
  124.     #Get one by the PK / ID with PK/ID == 1
  125.     seriesMessWith = Series.objects.get(pk=1)
  126.     ..do some changes...
  127.     Save it to the db with
  128.     seriesMessWith.save()
  129.     """
  130.     id = models.IntegerField(primary_key=True)
  131.     manufacturer_ID = models.ForeignKey(Manufacturer, unique=False)
  132.     name = models.CharField(max_length=50, null=True, blank=True)
  133.     page_name = models.CharField(max_length=100, null=True, blank=True)
  134.     description = models.TextField(null=True, blank=True)
  135.     image = models.ImageField(upload_to="imgs/", null=True, blank=True)
  136.     title_tag = models.CharField(max_length=250, null=True, blank=True)
  137.     description_tag = models.TextField(null=True, blank=True)
  138.     keywords_tag = models.TextField(null=True, blank=True)
  139.     #This will need to be changed
  140.     status = models.ForeignKey(Status, unique=False)
  141.  
  142.     def __unicode__(self):
  143.         return str(self.name)
  144.  
  145. class SeriesAdmin(admin.ModelAdmin):
  146.     """
  147.     This class is used by the admin interface to determine what fields are shown
  148.     when you look at an item in the list view, inside the admin panel.
  149.     It also defines the valid search fields using the default search engine
  150.     in Django
  151.     """
  152.     list_display = ('id', 'manufacturer_ID', 'name', 'status')
  153.     search_fields = ('id', 'manufacturer_ID', 'name', 'status')
  154.  
  155. #Register it with the Admin Interface
  156. admin.site.register(Series, SeriesAdmin)
  157.  
  158.  
  159. ##### Product Model ######
  160. class Product(models.Model):
  161.     """
  162.     This class defines the roles and properties of the Product table
  163.     It is based off of the Product table found inside pdfsupply.com's
  164.     PHP / MYSQL site.
  165.  
  166.     Usage:
  167.     #Make a new object
  168.     productToAdd = Product()
  169.  
  170.     #to give it an ID
  171.     productToAdd.id = x
  172.  
  173.     #Write it to the DB
  174.     productToAdd.save()
  175.  
  176.     #Get one by the PK / ID with PK/ID == 1
  177.     productToMessWith = Product.objects.get(pk=1)
  178.     ..do some changes...
  179.     Save it to the db with
  180.     productToMessWith.save()
  181.     """
  182.     id = models.IntegerField(primary_key=True)
  183.     series_ID = models.ForeignKey(Series, unique=False)
  184.     part_number = models.CharField(max_length=20, null=True, blank=True)
  185.     description = models.TextField(null=True, blank=True)
  186.     title_tag = models.CharField(max_length=250, null=True, blank=True)
  187.     description_tag = models.TextField(null=True, blank=True)
  188.     keywords_tag = models.TextField(null=True, blank=True)
  189.     typos = models.TextField(null=True, blank=True)
  190.     featured = models.IntegerField(null=True, blank=True)
  191.     remanufactured_inventory = models.IntegerField(null=True, blank=True)
  192.     remanufactured_price = models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True)
  193.     new_inventory = models.IntegerField(null=True, blank=True)
  194.     new_price = models.DecimalField(max_digits=12, decimal_places=2, null=True, blank=True)
  195.     stock_level = models.CharField(max_length=30, null=True, blank=True)
  196.     repair_time = models.CharField(max_length=30, null=True, blank=True)
  197.     youtube_link = models.CharField(max_length=20, null=True, blank=True)
  198.     condition = models.CharField(max_length=30, null=True, blank=True)
  199.     show_revision_links = models.IntegerField(null=True, blank=True)
  200.     group_tag = models.CharField(max_length=20, null=True, blank=True)
  201.     status = models.ForeignKey(Status, unique=False)
  202.  
  203.     def __unicode__(self):
  204.         return str(self.part_number)
  205.  
  206. class ProductAdmin(admin.ModelAdmin):
  207.     """
  208.     This class is used by the admin interface to determine what fields are shown
  209.     when you look at an item in the list view, inside the admin panel.
  210.     It also defines the valid search fields using the default search engine
  211.     in Django
  212.     """
  213.     list_display = ('id', 'series_ID', 'part_number', 'status')
  214.     search_fields = ('id', 'series_ID', 'part_number', 'status')
  215.  
  216. #Register it with the Admin Interface
  217. admin.site.register(Product, ProductAdmin)
  218.  
  219. ##### Revision Model ######
  220. class Revision(models.Model):
  221.     """
  222.     This class defines the roles and properties of the Product table
  223.     It is based off of the Product table found inside pdfsupply.com's
  224.     PHP / MYSQL site.
  225.  
  226.     Usage:
  227.     #Make a new object
  228.     revisionToAdd = Revision()
  229.  
  230.     #to give it an ID
  231.     revisionToAdd.id = x
  232.  
  233.     #Write it to the DB
  234.     revisionToAdd.save()
  235.  
  236.     #Get one by the PK / ID with PK/ID == 1
  237.     revisionToMessWith = Revision.objects.get(pk=1)
  238.     ..do some changes...
  239.     Save it to the db with
  240.     revisionToMessWith.save()
  241.     """
  242.     id = models.IntegerField(primary_key=True)
  243.     description = models.TextField(null=True, blank=True)
  244.     title_tag = models.CharField(max_length=250, null=True, blank=True)
  245.     description_tag = models.TextField(null=True, blank=True)
  246.     keywords_tag = models.TextField(null=True, blank=True)
  247.     group_tag = models.CharField(max_length=30, null=True, blank=True)
  248.     status = models.ForeignKey(Status, unique=False)
  249.  
  250.     def __unicode__(self):
  251.         return str(self.id)
  252.  
  253. class RevisionAdmin(admin.ModelAdmin):
  254.     """
  255.     This class is used by the admin interface to determine what fields are shown
  256.     when you look at an item in the list view, inside the admin panel.
  257.     It also defines the valid search fields using the default search engine
  258.     in Django
  259.     """
  260.     list_display = ('id', 'description', 'status')
  261.     search_fields = ('id', 'description', 'status')
  262.  
  263. #Register it with the Admin Interface
  264. admin.site.register(Revision, RevisionAdmin)