|
| 1 | +#!/usr/bin/env python2 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | + |
| 4 | +# Contest Management System - http://cms-dev.github.io/ |
| 5 | +# Copyright © 2014 Fabian Gundlach <[email protected]> |
| 6 | +# |
| 7 | +# This program is free software: you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU Affero General Public License as |
| 9 | +# published by the Free Software Foundation, either version 3 of the |
| 10 | +# License, or (at your option) any later version. |
| 11 | +# |
| 12 | +# This program is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU Affero General Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU Affero General Public License |
| 18 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +"""Print-job-related database interface for SQLAlchemy. |
| 21 | +
|
| 22 | +""" |
| 23 | + |
| 24 | +from __future__ import absolute_import |
| 25 | +from __future__ import print_function |
| 26 | +from __future__ import unicode_literals |
| 27 | + |
| 28 | +from sqlalchemy.schema import Column, ForeignKey |
| 29 | +from sqlalchemy.types import Integer, String, Unicode, DateTime, Boolean |
| 30 | +from sqlalchemy.orm import relationship, backref |
| 31 | + |
| 32 | +from . import Base, User |
| 33 | + |
| 34 | + |
| 35 | +class PrintJob(Base): |
| 36 | + """Class to store a print job. |
| 37 | +
|
| 38 | + """ |
| 39 | + __tablename__ = 'printjobs' |
| 40 | + |
| 41 | + # Auto increment primary key. |
| 42 | + id = Column( |
| 43 | + Integer, |
| 44 | + primary_key=True) |
| 45 | + |
| 46 | + # User (id and object) that did the submission. |
| 47 | + user_id = Column( |
| 48 | + Integer, |
| 49 | + ForeignKey(User.id, |
| 50 | + onupdate="CASCADE", ondelete="CASCADE"), |
| 51 | + nullable=False, |
| 52 | + index=True) |
| 53 | + user = relationship( |
| 54 | + User, |
| 55 | + backref=backref("printjobs", |
| 56 | + cascade="all, delete-orphan", |
| 57 | + passive_deletes=True)) |
| 58 | + |
| 59 | + # Submission time of the print job. |
| 60 | + timestamp = Column( |
| 61 | + DateTime, |
| 62 | + nullable=False) |
| 63 | + |
| 64 | + # Filename and digest of the submitted file. |
| 65 | + filename = Column( |
| 66 | + Unicode, |
| 67 | + nullable=False) |
| 68 | + digest = Column( |
| 69 | + String, |
| 70 | + nullable=False) |
| 71 | + |
| 72 | + done = Column( |
| 73 | + Boolean, |
| 74 | + nullable=False, |
| 75 | + default=False) |
| 76 | + |
| 77 | + status = Column( |
| 78 | + Unicode, |
| 79 | + nullable=True) |
0 commit comments