Exemplo n.º 1
0
class AgentUser(auth.models.User, auth.models.PermissionsMixin):
    user_type =models.CharField(max_length=10,default="agent")
    address = models.TextField(max_length=255)
    pincode = models.CharField(max_length=6, default='000000')
    city = models.ForeignKey(City,on_delete=models.CASCADE)
    state= models.ForeignKey(State,on_delete=models.CASCADE)
    mobile = models.CharField(max_length=255)
    birth_date= models.DateField(blank=True)
    proof_document= models.FileField(blank=True, upload_to='agent_proof_document')
    resume_document =models.FileField(blank=True, upload_to='agent_resume_document')
    image = models.ImageField(blank=True, upload_to='agent_image')
    interview_date =models.DateTimeField(blank=True, null=True)
    interviewed = models.BooleanField(default=False, blank=True)
    contacted = models.BooleanField(default=True)
    approved =models.BooleanField(default=False)

    def agent_approved(self):
        self.approved = True
        self.save()

    def __str__(self):
        return '@{}'.format(self.username)


    def get_absolute_url(self):
        return reverse_lazy('auctions:agent_profile', kwargs={'pk': self.pk})  # This represent after doing Comment Where user should redirect


    class Meta:
        verbose_name=('AgentUser')
        verbose_name_plural =('AgentUsers')
Exemplo n.º 2
0
class Tracks(models.Model):
    track_name = models.CharField(max_length=100)
    track_artist = models.CharField(max_length=100)
    track_album = models.CharField(max_length=100)
    track_length = models.FloatField()
    track_genre = models.CharField(max_length=100)
    track_language = models.CharField(max_length=50)
    track_number = models.IntegerField()
    track_image = models.FileField()
    actual_track = models.FileField()

    def __str__(self):
        return self.track_name

    def save(self):
        #Save to the database
        super(Tracks, self).save()

        #if genre doesn't exist add it
        try:
            genre_object = Genres.objects.get(genre_name=self.track_genre)
        except:
            genre_object = Genres.objects.create(genre_name=self.track_genre)
            genre_object.save()

        #Upload music to Gridfs using pymongo commands
        print("Uploading to GridFS")
        db = MongoClient().MusicDB
        fs = GridFSBucket(db)
        music_file = open(self.actual_track.path,
                          'rb')  #open the file in binary mode
        fs.upload_from_stream(self.track_name,
                              music_file.read())  #upload to gridfs
Exemplo n.º 3
0
class OccupationalHS(models.Model):
    contractor = models.ForeignKey(Contractor, on_delete=models.CASCADE)
    healthSafety = models.FileField(
        upload_to="healthSafety/", null=True, verbose_name="Health and Safety Performance Report")
    safety = models.FileField(upload_to="safety/", null=True,
                              verbose_name="Occupational Safety and Health Administration Procedures")
    generalAssessment = models.FileField(
        upload_to="generalAssessment/", null=True, verbose_name="General Assessment of Safety Attitudes")

    class Meta:
        abstract = False
Exemplo n.º 4
0
class PastPerformance(models.Model):
    contractor = models.ForeignKey(Contractor, on_delete=models.CASCADE)
    quality = models.FileField(upload_to="quality/", null=True,
                               verbose_name="Quality Level of Project Performance")
    completedTime = models.FileField(
        upload_to="completionTime/", null=True, verbose_name="Projects Completed on Time")
    completedBudjet = models.FileField(
        upload_to="completedBudjet/", null=True, verbose_name="Projects Completed on Budget")

    class Meta:
        abstract = False
Exemplo n.º 5
0
class Experience(models.Model):
    contractor = models.ForeignKey(Contractor, on_delete=models.CASCADE)
    projectType = models.FileField(
        upload_to="projectType/", null=True, verbose_name="Type of Past Projects Completed")
    projectSize = models.FileField(
        upload_to="projectSize/", null=True, verbose_name="Size of Past Projects Completed")
    numProject = models.FileField(
        upload_to="numProject/", null=True, verbose_name="Number of Past Projects Completed")
    localAreaExperience = models.FileField(
        upload_to="localAreaExperience/", null=True, verbose_name="Experience in Local Area")

    class Meta:
        abstract = False
Exemplo n.º 6
0
class Reputation(models.Model):
    contractor = models.ForeignKey(Contractor, on_delete=models.CASCADE)
    failures = models.FileField(
        upload_to="failures/", null=True, verbose_name="Past Failures")
    timeInBusiness = models.FileField(
        upload_to="timeInBusiness/", null=True, verbose_name="Length of time in Business")
    pastOwner = models.FileField(
        upload_to="pastOwner/", null=True, verbose_name="Past Owner / Contractor Relationship")
    relationships = models.FileField(
        upload_to="relationships/", null=True, verbose_name="Other Relationships")

    class Meta:
        abstract = False
Exemplo n.º 7
0
class ManagementCapability(models.Model):
    contractor = models.ForeignKey(Contractor, on_delete=models.CASCADE)
    qualityPolicy = models.FileField(
        upload_to="qualityPolicy/", null=True, verbose_name="Quality Policy")
    projectManagement = models.FileField(
        upload_to="projectManagement/", null=True, verbose_name="Project Management Organization")
    culture = models.FileField(
        upload_to="culture/", null=True, verbose_name="Organizational Culture")
    knowledge = models.FileField(
        upload_to="knowledge/", null=True, verbose_name="Management Knowledge")

    class Meta:
        abstract = False
Exemplo n.º 8
0
class TechnicalCapability(models.Model):
    contractor = models.ForeignKey(Contractor, on_delete=models.CASCADE)
    experience = models.FileField(
        upload_to="experience/", null=True, verbose_name="Experience of Technical Personnels")
    labour = models.FileField(
        upload_to="labour/", null=True, verbose_name="Labour and Equipment")
    qualification = models.FileField(
        upload_to="qualification/", null=True, verbose_name="Qualification of Personnels")
    ability = models.FileField(
        upload_to="ability/", null=True, verbose_name="Ability of Personnels")

    class Meta:
        abstract = False
Exemplo n.º 9
0
class FinancialStability(models.Model):
    contractor = models.ForeignKey(Contractor, on_delete=models.CASCADE)
    soundness = models.FileField(
        db_alias='soundness', collection_name='soundness', verbose_name="Financial Soundness")
    credit_rating = models.FileField(
        db_alias='credit_rating', collection_name='credit_rating', verbose_name="Financial Credit Rating")
    banking_bonding = models.FileField(db_alias='banking_bonding', collection_name='banking_bonding',
                                       verbose_name="Financial Arrangements and Bonding")
    status = models.FileField(db_alias='status', collection_name='status',
                              verbose_name="Financial Status")
    liquidity = models.FileField(
        db_alias='liquidity', collection_name='liquidity', verbose_name="Financial Liquidity")

    def __str__(self):
        return self.contractor.name
Exemplo n.º 10
0
class Bid2(models.Model):
    name = models.CharField(max_length=400)
    description = models.TextField()
    pub_date = models.DateTimeField(auto_now_add=True, null=True)
    mode_date = models.DateTimeField()
    activated = models.BooleanField(
        default=False, verbose_name='Activate Bid for Decision Makers')
    closed = models.BooleanField(default=False)
    status = models.FileField(db_alias='status', collection_name='status',
                              verbose_name="Financial Status")
    liquidity = models.FileField(
        db_alias='liquidity', collection_name='liquidity', verbose_name="Financial Liquidity")

    def __str__(self):
        return self.name
Exemplo n.º 11
0
class Case(models.Model):
    #Docs = models.ForeignKey(Docs, on_delete=models.CASCADE)
    CaseNumber = models.CharField(max_length=20)
    CaseName = models.CharField(max_length=20)
    CaseInfo = models.CharField(max_length=250)
    Medicines = models.CharField(max_length=100)
    DocUploads = models.FileField()
Exemplo n.º 12
0
class UploadFileUsers(models.Model):
    _id = models.ObjectIdField(primary_key=True)
    name = models.CharField(max_length=600)
    usersupload = models.CharField(max_length=300)
    coursecode = models.CharField(max_length=500)
    contentfile = models.FileField(default=MEDIA_ROOT,
                                   upload_to='files/%Y/%m/%d/')
    comment = models.TextField(max_length=900)
    created = models.DateField(default=timezone.now, editable=True)

    def __str__(self):
        return self.usersupload

    def __iter__(self):
        return self

    def getall(self):
        return {
            "id": str(self.pk),
            "name": self.name,
            "usersupload": self.usersupload,
            "coursecode": self.coursecode,
            "contentfile": str(self.contentfile),
            "comment": self.comment,
            "created": str(self.created)
        }

    def delete(self, *args, **kwargs):
        storage, path = self.contentfile.storage, self.contentfile.path
        super(UploadFileUsers, self).delete(*args, **kwargs)
        storage.delete(path)
Exemplo n.º 13
0
class Document(models.Model):
    description = models.CharField(max_length=255, blank=True)
    document = models.FileField(upload_to='media/')
    uploaded_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.description + " - " + self.document
Exemplo n.º 14
0
class Faculty(models.Model):
    faculty_id = models.CharField(max_length=7, null=False)
    faculty_name = models.CharField(max_length=30, null=True)
    designation = models.CharField(max_length=30, null=True)
    department = models.CharField(max_length=2,
                                  choices=DEPT_LIST,
                                  null=False,
                                  default='CE')
    image = models.FileField(upload_to='', blank=True, default='NoImage.png')
    # qualifications = models.ArrayField(model_container=Qualification, null=True)
    phone = PhoneNumberField(
        blank=False,
        null=False,
    )
    email = models.EmailField(blank=True, null=True)
    website = models.URLField(max_length=200, null=True)
    office = models.CharField(max_length=30, null=True)
    biography = models.TextField(null=True)
    specializations = models.ArrayField(model_container=Topic,
                                        model_form_class=TopicForm,
                                        null=True)
    teaching_interests = models.ArrayField(model_container=Topic, null=True)
    faculty_type = models.CharField(max_length=10, null=True)

    class Meta:
        verbose_name_plural = "faculties"
Exemplo n.º 15
0
class MatchContent(models.Model):
    match = models.EmbeddedField(model_container=MatchModel, null=False)

    match_image = models.FileField(blank=True)
    match_keyword = models.CharField(max_length=255)
    match_definition = models.TextField()
    objects = models.DjongoManager()
Exemplo n.º 16
0
class MediaDocument(mongo.Model):
    class ParentTypes(mongo.TextChoices):
        AVATAR = 'avatar', 'Avatar'
        POST = 'post', 'post'
        COMMENT = 'comment', 'comment'


    collection_name = 'media'
    database_name = 'media'
    objects = mongo.DjongoManager()

    id = mongo.CharField(max_length=36, db_column='_id', primary_key=True, default=utils.generate_uuid)
    media = mongo.FileField(storage=storage.GridFSStorage(collection=collection_name, database=database_name))
    content_type = mongo.TextField()
    length = mongo.IntegerField()
    created_on = mongo.DateTimeField(default=timezone.now)
    parent_id = mongo.CharField(max_length=36, null=True)
    parent_type = mongo.CharField(choices=ParentTypes.choices, default=ParentTypes.POST, max_length=15)

    def get_url(self):
        return reverse_lazy('view_media', kwargs={'pk': self.pk})

    def stream(self):
        return self.media.file

    def stream_image(self, request, *args, **kwargs):
        stream = self.stream()
        response = FileResponse(stream, content_type=self.content_type)
        return utils.cache_response(response)

    def stream_video(self, request, *args, **kwargs):
        stream = self.stream()
        response = FileResponse(stream, content_type=self.content_type)
        return utils.stream_response(request, response, self.length)

    def stream_media(self, *args, **kwargs):
        try:
            content_type = self.content_type.split('/')[0]
        except AttributeError:
            raise Exception('Unknown media type')

        if content_type == 'image':
            return self.stream_image(*args, **kwargs)
        elif content_type == 'video':
            return self.stream_video(*args, **kwargs)
        else:
            raise Exception('Media type not supported')

    def upload(self, upload_stream):
        #upload_stream = images.optimize_media(upload_stream)
        self.media = upload_stream
        self.content_type = upload_stream.content_type
        self.length = upload_stream.size
        self.save()
        return self

    class Meta:
        db_table = 'media'
        db = settings.MEDIA_DATABASE
class FileInfo(models.Model):
    share_code = models.CharField(max_length=100, unique=True)
    file_size = models.IntegerField()
    file_name = models.CharField(max_length=100)
    download_count = models.IntegerField()
    create_user = models.CharField(max_length=100)
    file_expire_time = models.DateTimeField()
    file = models.FileField(upload_to=path_and_rename)
Exemplo n.º 18
0
class Inspect(models.Model):
    I_id = models.CharField(max_length=10)
    officer = models.CharField(max_length=100)
    date = models.DateField(auto_now=True)
    file = models.FileField(upload_to='Inspect')

    class Meta:
        app_label = 'Distributor'
Exemplo n.º 19
0
class Dataset(models.Model):
    """ Datasets model definition """
    dataset_id = models.CharField(max_length=150, editable=False, unique=True)
    name = models.CharField(max_length=50, db_column='name')
    namespaces_file = models.FileField()
    datapoints_file = models.FileField()
    columns_file = models.FileField()
    created_at = models.DateTimeField(auto_now_add=True)

    objects = models.DjongoManager()

    def __init__(self):
        super(Dataset, self).__init__()
        self.dataset_id = str(uuid.uuid4())

    class Meta:
        db_table = 'datasets'
Exemplo n.º 20
0
class Dataset(models.Model):
    _id = models.ObjectIdField()
    dataset_id = models.IntegerField()
    submitter_name = models.CharField(max_length=64)
    relevant_questions = models.ListField()
    actual_data = models.FileField()
    is_approved = models.BooleanField(default=False)

    objects = models.DjongoManager()
Exemplo n.º 21
0
class Proofs(models.Model):
    _id = models.ObjectIdField()
    proof = models.FileField(upload_to="uploads/",
                             default='',
                             blank=True,
                             null=True)

    def __str__(self):
        return os.path.basename(self.proof.name)
Exemplo n.º 22
0
class Answer(models.Model):

    answer = models.CharField(max_length=200)
    files = models.FileField(null=True, blank=True)
    created = models.DateTimeField(auto_now_add=True,
                                   verbose_name="Fecha de creación")

    class Meta:
        abstract = True
Exemplo n.º 23
0
class Question(models.Model):
    _id = models.ObjectIdField(default=None)
    question_id = models.IntegerField(default=None)
    submitting_user = models.CharField(max_length=64, default="")
    title = models.CharField(
        max_length=64)  #char fields are directly translated to MongoDB Strings
    spec = models.FileField(upload_to='uploads')
    number_of_submissions = models.IntegerField(
    )  #Integer Fields will be translated to one of the MongoDB Integer types (I don't actually know which one, I think int32)
    best_solution = models.FileField()
    language = models.CharField(max_length=64)
    datasets = models.FileField(upload_to='uploads')
    code = models.FileField(upload_to='uploads')
    tags = models.ListField(
    )  #List fields are the Array BSON type and allow us to store compound data along with DictFields, making us unormalized, but this is standard for NoSQL pattern databases.
    is_approved = models.BooleanField(default=False)
    creation_date = models.DateTimeField(default=None)

    objects = models.DjongoManager()
Exemplo n.º 24
0
class Organization(models.Model):
    org_id = models.AutoField(primary_key=True)
    org_name = models.CharField(max_length=256, unique=True)
    address = models.JSONField(null=False, blank=False)
    status = models.BooleanField(default=False)
    inventory_items_refresh_job = models.IntegerField(default=1)
    repeat_interval = models.CharField(max_length=256, default='days')
    ftp_location = models.CharField(max_length=256, null=True)
    calendar_date = models.CharField(max_length=100)
    file = models.FileField(null=True)
Exemplo n.º 25
0
class Archivo(models.Model):
    user            = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    nombre          = models.CharField(max_length=120)
    archivo         = models.FileField(upload_to='archivos', storage=grid_fs_storage)
    id_loc          = models.IntegerField()
    id_tipo_archivo = models.IntegerField()
    slug            = models.SlugField(blank=True, null=True)

    def __str__(self):
        return self.nombre
Exemplo n.º 26
0
class NodeDocument(models.Model):
    """ A Model defining a document (or file) uploaded against a node by a user """
    _id = models.ObjectIdField()

    # The file stored on S3 through django-storages
    # NOTE - To set this from an existing file, just save the model using document=<path_to_file_on_s3> (key)
    document = models.FileField()

    # The User who uploaded the file
    uploaded_by = models.ForeignKey(MyUser, on_delete=models.CASCADE)
    # Node the document was uploaded against
    node = models.ForeignKey(TreeStructure,
                             on_delete=models.CASCADE,
                             related_name="node_documents")

    # Misc details
    uploaded_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return "<Document:{}>".format(self.uploaded_by.username)

    def set_document(self, filename, document):
        """ Document MUST be a bytes object; ex: ContentFile(b'randText') """
        self.document.save(filename, document)

    def rename_document(self, new_name):
        """ Renames an s3 file by sending a copy object request
            from the old_name to the new_name
            new-name = a generic file name NOT prefixed by the nodeID
        """
        client = generate_s3_client()

        if self.document:
            # Copying over the old file to the new file
            source = {
                "Bucket": settings.AWS_STORAGE_BUCKET_NAME,
                "Key": self.document.name
            }
            new_name = self.gen_filename(self.node, new_name)
            response = client.copy_object(
                CopySource=source,
                Bucket=settings.AWS_STORAGE_BUCKET_NAME,
                Key=new_name)
            # Setting the name in the database
            self.document.name = new_name
            self.save()

            return self.document.name

        return None

    @staticmethod
    def gen_filename(node, filename):
        return "{node_id}/{filename}".format(node_id=str(node._id),
                                             filename=filename)
Exemplo n.º 27
0
class QueryImage(models.Model):
    _id = models.ObjectIdField()
    file = models.FileField(blank=False, null=False)
    url = models.URLField(blank=True, null=True)
    created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.file.name

    class Meta:
        ordering = ['created']
Exemplo n.º 28
0
class Video(models.Model):
    title = models.CharField(max_length=60)
    desc = models.TextField()
    channel = models.CharField(max_length=30)
    image = models.ImageField(blank=False)
    video = models.FileField(blank=False)
    views = models.IntegerField(null=True)
    time = models.DateTimeField(auto_now=True)

    def __str__(self):
        return (self.title)
Exemplo n.º 29
0
class Content(models.Model):
    attachment = models.FileField(upload_to='uploadContent/',
                                  blank=True,
                                  null=False)
    textContent = models.TextField(blank=False)

    def __str__(self):
        if self.attachment is not None:
            return self.attachment.name
        elif self.textContent is not None:
            return self.response_content[:20]
Exemplo n.º 30
0
class CommonFile(models.Model):
    user = models.ForeignKey(CommonUser, on_delete=models.CASCADE)
    patient_name = models.CharField(max_length=255)
    file = models.FileField(upload_to=user_directory_path)
    created_at = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return str(self.user)

    def is_owner(self, user):
        if self.user == user:
            return True
        return False