summaryrefslogtreecommitdiff
path: root/inventory/fabmap/models.py
blob: e73179f88e9917c1049bc244dd47d8994a0d7240 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
from django.db import models
from django.contrib.auth.models import User
from django.contrib import admin

from django import forms
from django.forms import ModelForm

#
#       Defining models
#
#

class AccessModel(models.Model):
        name = models.CharField(max_length=200)
        description = models.TextField()

        def __unicode__(self):
                return self.name

class EquipmentCapability(models.Model):
        name = models.CharField(max_length=200)

        def __unicode__(self):
                return self.name

class EquipmentType(models.Model):
        name = models.CharField(max_length=200)
        maker = models.CharField(max_length=200)
        website = models.URLField(blank=True)
        capabilities = models.ManyToManyField(EquipmentCapability)

        def __unicode__(self):
                return self.maker + " " + self.name

class Site(models.Model):
        lat = models.FloatField("Latitude")
        lon = models.FloatField("Longitude")
        name = models.CharField("Site name", max_length=200)
        locname = models.CharField("Town/city", max_length=200)
        website = models.URLField(blank=True)
        manager = models.ForeignKey(User)
        access = models.ForeignKey(AccessModel, verbose_name="Access model")

        def __unicode__(self):
                return self.name

class Equipment(models.Model):
        type = models.ForeignKey(EquipmentType)
        site = models.ForeignKey(Site)
        notes = models.TextField()

        def __unicode__(self):
                return self.type

# class Material(models.Model):
#       # DEFINEME
#       name = models.CharField(max_length=500)
#       formula = models.CharField(max_length=200, blank=True)
#       iselement = models.BooleanField()
#       description = models.TextField(blank=True)
#       
#       meltingpoint = models.FloatField("Melting point", blank=True)
#       boilingpoint = models.FloatField("Boiling point", blank=True)
#       
#       density = models.FloatField(blank=True)
#       
#       modulus_elasticity = models.FloatField("Modulus of elasticity", blank=True)
#       modulus_youngs = models.FloatField("Young's modulus", blank=True)
#       
#       hardness_mohs = models.FloatField(blank=True)
#       hardness_brinnel = models.FloatField(blank=True)
#       
#       thermal_inductance = models.FloatField(blank=True)
#       thermal_capacity = models.FloatField(blank=True)
#       thermal_expansion = models.FloatField("Coefficient of thermal expansion (CTE)", blank=True)
#       
#       electrical_inductance = models.FloatField(blank=True)
#       electrical_capacity = models.FloatField(blank=True)
#       # nuclear profile? radioactivity_profile?
#       # electrical profile?
#       # thermal profile?
#       
#class MaterialProperty(models.Model):
#       name = models.CharField(max_length=200)
#       
#
#class Method(models.Model):    # Process? Method? TODO: DECIDE ON TERMINOLOGY
#       # DEFINEME
#       pass
#       

#
#       Registering tables with admin site
#
#

admin.site.register(EquipmentType)
admin.site.register(Site)
admin.site.register(EquipmentCapability)
admin.site.register(Equipment)
admin.site.register(AccessModel)


#
#       Defining forms
#
#

class SiteForm(ModelForm):
        class Meta:
                model = Site
                exclude = ('manager')