Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 99c92c11

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

re #9429 Added class and funcionality for Teams table. Modified date parsing and storing. Modified View at /usb-logs/. Replaced "_" with "-" in all endpoints.

Zobrazit rozdíly:

server/sql_app/models.py
1
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
1
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, DateTime
2 2
from sqlalchemy.orm import relationship
3

  
3
from sqlalchemy.sql import func
4 4
from .database import Base
5 5

  
6 6

  
......
8 8
    __tablename__ = "devices"
9 9

  
10 10
    id = Column(Integer, primary_key=True, index=True)
11
    vendor_id = Column(Integer, index=True, nullable=False)
12
    product_id = Column(Integer, index=True, nullable=False)
11
    vendor_id = Column(String, index=True, nullable=False)
12
    product_id = Column(String, index=True, nullable=False)
13 13
    serial_number = Column(String, index=True, nullable=False)
14
    assigned = Column(Boolean, index=True, nullable=False)
14 15

  
15 16
    logs = relationship("USBLog", back_populates="device")
16 17
    licenses = relationship("DeviceLicense", back_populates="device_lic")
......
21 22

  
22 23
    id = Column(Integer, primary_key=True, index=True)
23 24
    pc_id = Column(Integer, ForeignKey("pc.id"))
24
    timestamp = Column(String, index=True, nullable=False)
25
    timestamp = Column(DateTime(timezone=True), server_default=func.now())
25 26
    status = Column(String, index=True, nullable=False)
26 27
    device_id = Column(Integer, ForeignKey("devices.id"))
27 28

  
......
34 35

  
35 36
    id = Column(Integer, primary_key=True, index=True)
36 37
    name = Column(String, index=True, nullable=False)
37
    expiration_date = Column(String, index=True, nullable=False)
38
    expiration_date = Column(DateTime(timezone=True), server_default=func.now())
38 39

  
39 40
    devices = relationship("DeviceLicense", back_populates="licenses")
40 41

  
......
43 44
    __tablename__ = "devices_licenses"
44 45

  
45 46
    id = Column(Integer, primary_key=True, index=True)
46
    device_id = Column(Integer, ForeignKey("devices.id"))
47
    license_id = Column(Integer, ForeignKey("licenses.id"))
47
    device_id = Column(String, ForeignKey("devices.id"))
48
    license_id = Column(String, ForeignKey("licenses.id"))
48 49
    assigned_datetime = Column(String, index=True, nullable=False)
49 50

  
50 51
    device_lic = relationship("Device", back_populates="licenses")
......
57 58
    id = Column(Integer, primary_key=True, index=True)
58 59
    username = Column(String, index=True, nullable=False)
59 60
    hostname = Column(String, index=True, nullable=False)
61
    assigned = Column(Boolean, index=True, nullable=False)
62
    team_id = Column(Integer, ForeignKey("teams.id"))
63

  
64
    team = relationship("Team", back_populates="pcs")
60 65
    logs_pc = relationship("USBLog", back_populates="pc")
66

  
67

  
68
class Team(Base):
69
    __tablename__ = "teams"
70

  
71
    id = Column(Integer, primary_key=True, index=True)
72
    name = Column(String, index=True, nullable=False)
73
    pcs = relationship("PC", back_populates="team")

Také k dispozici: Unified diff