# Path: uploads/models.py
# class Document(models.Model):
#     """Note that a number of fields have indexes in the database despite
#     lacking them here:
# 
#     mysql> show index from uploads_document;
#         +------------------+-----------------+-------------+-------------+
#         | Table            | Key_name        | Column_name | Cardinality |
#         +------------------+-----------------+-------------+-------------+
#         | uploads_document | PRIMARY         | id          |    26652929 |
#         | uploads_document | court           | court       |         206 |
#         | uploads_document | court           | casenum     |     1025112 |
#         | uploads_document | court           | docnum      |    26652929 |
#         | uploads_document | court           | subdocnum   |    26652929 |
#         | uploads_document | docid_idx       | docid       |    26652929 |
#         | uploads_document | document_free_i | free_import |           2 |
#         | uploads_document | lastdateindex   | lastdate    |    26652929 |
#         | uploads_document | modifiedindex   | modified    |     6663232 |
#         +------------------+-----------------+-------------+-------------+
# 
#     (https://dev.mysql.com/doc/refman/5.0/en/show-index.html)
# 
#     """
#     court = models.CharField(
#         maxlength=10,
#     )
#     casenum = models.CharField(
#         maxlength=30,
#     )
#     docnum = models.CharField(
#         maxlength=30,
#     )
#     subdocnum = models.CharField(
#         maxlength=30,
#     )
#     docid = models.CharField(
#         maxlength=32,
#         null=True,
#         blank=True,
#         db_index=True,
#     )
#     de_seq_num = models.PositiveIntegerField(
#         null=True,
#         blank=True,
#     )
#     dm_id = models.PositiveIntegerField(
#         null=True,
#         blank=True,
#     )
#     sha1 = models.CharField(
#         maxlength=40,
#         null=True,
#         blank=True,
#     )
#     available = models.BooleanField(
#         default=0,
#     )
#     lastdate = models.DateTimeField(
#         null=True,
#         blank=True,
#         db_index=True,
#     )
#     modified = models.DateTimeField(
#         null=True,
#         blank=True,
#         auto_now_add=True,
#         db_index=True,
#     )
#     free_import = models.BooleanField(
#         default=0,
#         db_index=True,
#     )
#     team_name = models.CharField(
#         maxlength=40,
#         null=True,
#         blank=True
#     )
# 
#     class Meta:
#         unique_together = (
#             (
#                 "court",
#                 "casenum",
#                 "docnum",
#                 "subdocnum",
#             ),
#         )


import sys, os
import remove_document, urllib2
import InternetArchiveCommon as IACommon
from uploads.models import Document
        exit()

    try:
        court, casenum = sys.argv[1].split(".")
    except ValueError:
        print "Error: could not parse command line arguments\n"
        print usage()
        exit()

    return court, casenum


def get_documents(court, casenum):
    query = Document.objects.filter(court=court,
                                    casenum=casenum)

    if len(query) == 0:
        print "No documents belong to %s.%s" % (court, casenum)
        print usage()
        exit()
    return query


def main():
    court, casenum = get_court_casenum_from_argv()
    documents = get_documents(court, casenum)
    for document in documents:
        if document.available:
            print document.docnum
            print document.subdocnum

# Path: uploads/models.py
# class Document(models.Model):
#     """Note that a number of fields have indexes in the database despite
#     lacking them here:
# 
#     mysql> show index from uploads_document;
#         +------------------+-----------------+-------------+-------------+
#         | Table            | Key_name        | Column_name | Cardinality |
#         +------------------+-----------------+-------------+-------------+
#         | uploads_document | PRIMARY         | id          |    26652929 |
#         | uploads_document | court           | court       |         206 |
#         | uploads_document | court           | casenum     |     1025112 |
#         | uploads_document | court           | docnum      |    26652929 |
#         | uploads_document | court           | subdocnum   |    26652929 |
#         | uploads_document | docid_idx       | docid       |    26652929 |
#         | uploads_document | document_free_i | free_import |           2 |
#         | uploads_document | lastdateindex   | lastdate    |    26652929 |
#         | uploads_document | modifiedindex   | modified    |     6663232 |
#         +------------------+-----------------+-------------+-------------+
# 
#     (https://dev.mysql.com/doc/refman/5.0/en/show-index.html)
# 
#     """
#     court = models.CharField(
#         maxlength=10,
#     )
#     casenum = models.CharField(
#         maxlength=30,
#     )
#     docnum = models.CharField(
#         maxlength=30,
#     )
#     subdocnum = models.CharField(
#         maxlength=30,
#     )
#     docid = models.CharField(
#         maxlength=32,
#         null=True,
#         blank=True,
#         db_index=True,
#     )
#     de_seq_num = models.PositiveIntegerField(
#         null=True,
#         blank=True,
#     )
#     dm_id = models.PositiveIntegerField(
#         null=True,
#         blank=True,
#     )
#     sha1 = models.CharField(
#         maxlength=40,
#         null=True,
#         blank=True,
#     )
#     available = models.BooleanField(
#         default=0,
#     )
#     lastdate = models.DateTimeField(
#         null=True,
#         blank=True,
#         db_index=True,
#     )
#     modified = models.DateTimeField(
#         null=True,
#         blank=True,
#         auto_now_add=True,
#         db_index=True,
#     )
#     free_import = models.BooleanField(
#         default=0,
#         db_index=True,
#     )
#     team_name = models.CharField(
#         maxlength=40,
#         null=True,
#         blank=True
#     )
# 
#     class Meta:
#         unique_together = (
#             (
#                 "court",
#                 "casenum",
#                 "docnum",
#                 "subdocnum",
#             ),
#         )


# Path: uploads/remove_docket.py
import sys, os
import remove_document, urllib2
import InternetArchiveCommon as IACommon
from uploads.models import Document

        exit()

    try:
        court, casenum = sys.argv[1].split(".")
    except ValueError:
        print "Error: could not parse command line arguments\n"
        print usage()
        exit()

    return court, casenum


def get_documents(court, casenum):
    query = Document.objects.filter(court=court,
                                    casenum=casenum)

    if len(query) == 0:
        print "No documents belong to %s.%s" % (court, casenum)
        print usage()
        exit()
    return query


def main():
    court, casenum = get_court_casenum_from_argv()
    documents = get_documents(court, casenum)
    for document in documents:
        if document.available:
            print document.docnum
            print document.subdocnum

            remove_document.archive_document_locally(document)