models/dissertation_document_file.py
Similar blocks of code found in 2 locations. Consider refactoring.##############################################################################Similar blocks of code found in 2 locations. Consider refactoring.#Similar blocks of code found in 2 locations. Consider refactoring.# OSIS stands for Open Student Information System. It's an applicationSimilar blocks of code found in 2 locations. Consider refactoring.# designed to manage the core business of higher education institutions,Similar blocks of code found in 2 locations. Consider refactoring.# such as universities, faculties, institutes and professional schools.Similar blocks of code found in 2 locations. Consider refactoring.# The core business involves the administration of students, teachers,Similar blocks of code found in 2 locations. Consider refactoring.# courses, programs and so on.Similar blocks of code found in 2 locations. Consider refactoring.#Similar blocks of code found in 2 locations. Consider refactoring.# Copyright (C) 2015-2019 Université catholique de Louvain (http://www.uclouvain.be)Similar blocks of code found in 2 locations. Consider refactoring.#Similar blocks of code found in 2 locations. Consider refactoring.# This program is free software: you can redistribute it and/or modifySimilar blocks of code found in 2 locations. Consider refactoring.# it under the terms of the GNU General Public License as published bySimilar blocks of code found in 2 locations. Consider refactoring.# the Free Software Foundation, either version 3 of the License, orSimilar blocks of code found in 2 locations. Consider refactoring.# (at your option) any later version.Similar blocks of code found in 2 locations. Consider refactoring.#Similar blocks of code found in 2 locations. Consider refactoring.# This program is distributed in the hope that it will be useful,Similar blocks of code found in 2 locations. Consider refactoring.# but WITHOUT ANY WARRANTY; without even the implied warranty ofSimilar blocks of code found in 2 locations. Consider refactoring.# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theSimilar blocks of code found in 2 locations. Consider refactoring.# GNU General Public License for more details.Similar blocks of code found in 2 locations. Consider refactoring.#Similar blocks of code found in 2 locations. Consider refactoring.# A copy of this license - GNU General Public License - is availableSimilar blocks of code found in 2 locations. Consider refactoring.# at the root of the source code of this program. If not,Similar blocks of code found in 2 locations. Consider refactoring.# see http://www.gnu.org/licenses/.Similar blocks of code found in 2 locations. Consider refactoring.#Similar blocks of code found in 2 locations. Consider refactoring.##############################################################################Similar blocks of code found in 2 locations. Consider refactoring.from django.db import modelsSimilar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring.from osis_common.models.serializable_model import SerializableModel, SerializableModelAdminSimilar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring.class DissertationDocumentFileAdmin(SerializableModelAdmin):Similar blocks of code found in 2 locations. Consider refactoring. list_display = ('dissertation', 'document_file')Similar blocks of code found in 2 locations. Consider refactoring. raw_id_fields = ('dissertation', 'document_file')Similar blocks of code found in 2 locations. Consider refactoring. search_fields = ('uuid',)Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring.class DissertationDocumentFile(SerializableModel):Similar blocks of code found in 2 locations. Consider refactoring. dissertation = models.ForeignKey('Dissertation', on_delete=models.CASCADE)Similar blocks of code found in 2 locations. Consider refactoring. document_file = models.ForeignKey('osis_common.DocumentFile', on_delete=models.CASCADE)Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. def __str__(self):Similar blocks of code found in 2 locations. Consider refactoring. return str(self.dissertation)Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring.def search(dissertation=None, description=None):Similar blocks of code found in 2 locations. Consider refactoring. out = NoneSimilar blocks of code found in 2 locations. Consider refactoring. queryset = DissertationDocumentFile.objects.order_by('document_file__creation_date')Similar blocks of code found in 2 locations. Consider refactoring. if dissertation:Similar blocks of code found in 2 locations. Consider refactoring. queryset = queryset.filter(dissertation=dissertation)Similar blocks of code found in 2 locations. Consider refactoring. if description:Similar blocks of code found in 2 locations. Consider refactoring. queryset = queryset.filter(document_file__description=description)Similar blocks of code found in 2 locations. Consider refactoring. if dissertation or description:Similar blocks of code found in 2 locations. Consider refactoring. out = querysetSimilar blocks of code found in 2 locations. Consider refactoring. return outSimilar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring.def find_by_dissertation(dissertation):Similar blocks of code found in 2 locations. Consider refactoring. return DissertationDocumentFile.objects.filter(dissertation=dissertation)