Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 6ad54e2e

Přidáno uživatelem Matěj Zeman před více než 2 roky(ů)

Changed looks of tables with simple css. Added inventory number and comment to Lauterbach devices. Changed connection between lauterbach devices and license.

Zobrazit rozdíly:

server/sql_app/models.py
25 25
    licenses = relationship("DeviceLicense", back_populates="device_lic")
26 26
    team = relationship("Team", back_populates="devices")
27 27

  
28

  
28 29
class USBLog(Base):
29 30
    """
30 31
    Class defining database table usb_logs
......
50 51
    __tablename__ = "licenses"
51 52

  
52 53
    id = Column(Integer, primary_key=True, index=True)
53
    name = Column(String, index=True, nullable=False)
54
    name = Column(String, index=True, nullable=True)
54 55
    license_id = Column(String, index=True, nullable=False)
55 56
    expiration_date = Column(DateTime(timezone=True), nullable=True)
56 57

  
57 58
    # relationships for foreign keys, thus connecting table with devices table
58 59
    devices = relationship("DeviceLicense", back_populates="licenses")
59
    body_devices = relationship("BodyDeviceLicense", back_populates="b_licenses")
60
    bodydevice_lic = relationship("BodyDevice", back_populates="license")
61
    headdevice_lic = relationship("HeadDevice", back_populates="license")
62

  
60 63

  
61 64
class DeviceLicense(Base):
62 65
    """
......
75 78
    licenses = relationship("License", back_populates="devices")
76 79

  
77 80

  
78
class BodyDeviceLicense(Base):
79
    """
80
    Class defining database table bodydevices_licenses
81
    """
82
    __tablename__ = "bodydevices_licenses"
83

  
84
    id = Column(Integer, primary_key=True, index=True)
85
    bodydevice_id = Column(Integer, ForeignKey("body_devices.id"))
86
    license_id = Column(Integer, ForeignKey("licenses.id"))
87
    assigned_datetime = Column(String, index=True, nullable=False)
88

  
89
    # relationships for foreign keys, thus connecting table with devices and licenses
90
    # tables
91
    bodydevice_lic = relationship("BodyDevice", back_populates="debug_licenses")
92
    b_licenses = relationship("License", back_populates="body_devices")
93

  
94

  
95 81
class PC(Base):
96 82
    """
97 83
    Class defining database table pc
......
118 104
    name = Column(String, index=True, nullable=False)
119 105

  
120 106
    devices = relationship("Device", back_populates="team")
107
    body_devices = relationship("BodyDevice", back_populates="team")
108
    head_devices = relationship("HeadDevice", back_populates="team")
109

  
121 110

  
122 111
class HeadDevice(Base):
123 112
    """
......
127 116

  
128 117
    id = Column(Integer, primary_key=True, index=True)
129 118
    serial_number = Column(String, index=True, nullable=False)
119
    inventory_number = Column(String, index=True, nullable=True)
120
    comment = Column(String, index=True, nullable=True)
121

  
122
    team_id = Column(Integer, ForeignKey("teams.id"))
123
    license_id = Column(Integer, ForeignKey("licenses.id"))
130 124

  
131 125
    # relationships for foreign keys, thus connecting table with ld_logs table
132 126
    h_logs = relationship("LDLog", back_populates="head_device")
127
    license = relationship("License", back_populates="headdevice_lic")
128
    team = relationship("Team", back_populates="head_devices")
133 129

  
134 130

  
135 131
class BodyDevice(Base):
......
140 136

  
141 137
    id = Column(Integer, primary_key=True, index=True)
142 138
    serial_number = Column(String, index=True, nullable=False)
139
    inventory_number = Column(String, index=True, nullable=True)
140
    comment = Column(String, index=True, nullable=True)
141

  
142
    team_id = Column(Integer, ForeignKey("teams.id"))
143
    license_id = Column(Integer, ForeignKey("licenses.id"))
143 144

  
144 145
    # relationships for foreign keys, thus connecting table with ld_logs table
145 146
    b_logs = relationship("LDLog", back_populates="body_device")
146
    debug_licenses = relationship("BodyDeviceLicense", back_populates="bodydevice_lic")
147
    license = relationship("License", back_populates="bodydevice_lic")
148
    team = relationship("Team", back_populates="body_devices")
147 149

  
148 150

  
149 151
class LDLog(Base):
......
165 167
    head_device = relationship("HeadDevice", back_populates="h_logs")
166 168
    body_device = relationship("BodyDevice", back_populates="b_logs")
167 169

  
170

  
168 171
class User(Base):
169 172
    """
170 173
    Class defining user in database with its own role

Také k dispozici: Unified diff