From a583d78591a326033ba52ce641893c4846e5f5f9 Mon Sep 17 00:00:00 2001 From: Harald Nezbeda Date: Mon, 15 Nov 2021 16:32:14 +0100 Subject: [PATCH] Rename module --- CHANGELOG.md | 4 +-- CONTRIBUTING.md | 32 +------------------ MANIFEST.in | 3 -- README.md | 10 +++--- .../admin.py | 2 +- .../apps.py | 4 +-- .../handlers.py | 2 +- .../migrations/0001_initial.py | 4 +-- .../migrations/__init__.py | 0 .../models/__init__.py | 0 .../models/managers.py | 2 +- .../models/models.py | 6 ++-- .../models/querysets.py | 0 .../rest/__init__.py | 0 .../rest/renderers.py | 0 .../rest/serializers.py | 2 +- .../rest/views.py | 6 ++-- .../static/attachments/attachment_admin.css | 0 .../uitls.py | 0 setup.py | 4 +-- tests/settings.py | 8 ++--- 21 files changed, 27 insertions(+), 62 deletions(-) delete mode 100644 MANIFEST.in rename {django_attachments => drf_attachments}/admin.py (94%) rename {django_attachments => drf_attachments}/apps.py (92%) rename {django_attachments => drf_attachments}/handlers.py (87%) rename {django_attachments => drf_attachments}/migrations/0001_initial.py (87%) rename {django_attachments => drf_attachments}/migrations/__init__.py (100%) rename {django_attachments => drf_attachments}/models/__init__.py (100%) rename {django_attachments => drf_attachments}/models/managers.py (72%) rename {django_attachments => drf_attachments}/models/models.py (98%) rename {django_attachments => drf_attachments}/models/querysets.py (100%) rename {django_attachments => drf_attachments}/rest/__init__.py (100%) rename {django_attachments => drf_attachments}/rest/renderers.py (100%) rename {django_attachments => drf_attachments}/rest/serializers.py (96%) rename {django_attachments => drf_attachments}/rest/views.py (91%) rename {django_attachments => drf_attachments}/static/attachments/attachment_admin.css (100%) rename {django_attachments => drf_attachments}/uitls.py (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 050c710..849cc8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,5 +6,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -[Unreleased]: https://github.com/anexia-it/django-attachments/compare/1.0.0...HEAD -[1.0.0]: https://github.com/anexia-it/django-attachments/releases/tag/1.0.0 \ No newline at end of file +[Unreleased]: https://github.com/anexia-it/drf-attachments/compare/1.0.0...HEAD +[1.0.0]: https://github.com/anexia-it/drf-attachments/releases/tag/1.0.0 \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d453900..21dffcf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,34 +32,4 @@ and patterns in the existing code-base. ### Contribution guidelines - Your code should follow PEP 8 -- Style Guide for Python Code - - Your changes should be covered by unit-tests - -## Setup local tests (venv) - -After forking the repository you may create a `venv` to manage all dependencies required for running the tests: -``` -python -m virtualenv venv -``` - -You can than enter the newly created `venv` and install all dependencies required for the tests: -``` -user@computer: source venv/bin/activate -(venv) user@computer: pip install -r requirements.txt -(venv) user@computer: pip install -e . -``` - -A quick check via `pip freeze` should list all relevant dependency packages plus the `django-attachments`: -``` -(venv) user@computer: pip freeze -Django==2.2.24 -# Editable Git install with no remote (django-attachments==0.0.0) --e /media/alex/INTENSO/ANX/pycharmWorkspace/django-attachments -python-magic==0.4.24 -pytz==2021.3 -sqlparse==0.4.2 -``` - -Now you should be able to successfully run the tests provided in `/tests/`: -``` -(venv) user@computer: python tests/manage.py test test tests/test/ -``` \ No newline at end of file + - Your changes should be covered by unit-tests \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index d3f0593..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include LICENSE -include README.md -recursive-include docs * \ No newline at end of file diff --git a/README.md b/README.md index f7adb03..b701920 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# Django Attachments +# DRF Attachments -A django module to manage any model's file up-/downloads by relating an Attachment model to it. +Django rest framework module to manage any model's file up-/downloads by relating an Attachment model to it. ## Installation Install using pip: ``` -pip install git+https://github.com/anexia-it/django-attachments@main +pip install git+https://github.com/anexia-it/drf-attachments@main ``` Add model_prefix to your INSTALLED_APPS list. Make sure it is the first app in the list @@ -15,7 +15,7 @@ Add model_prefix to your INSTALLED_APPS list. Make sure it is the first app in t ``` INSTALLED_APPS = [ ... - 'django_attachments', + 'drf_attachments', ... ] ``` @@ -114,7 +114,7 @@ To manage file uploads for any existing model you must create a one-to-many "att 5. Add attachment DRF route ``` - from django_attachments.rest.views import AttachmentViewSet + from drf_attachments.rest.views import AttachmentViewSet router = get_api_router() router.register(r"attachment", AttachmentViewSet) diff --git a/django_attachments/admin.py b/drf_attachments/admin.py similarity index 94% rename from django_attachments/admin.py rename to drf_attachments/admin.py index db24f2d..93880a0 100644 --- a/django_attachments/admin.py +++ b/drf_attachments/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from django.contrib.contenttypes.admin import GenericTabularInline -from django_attachments.models.models import Attachment +from drf_attachments.models.models import Attachment __all__ = [ "AttachmentInlineAdmin", diff --git a/django_attachments/apps.py b/drf_attachments/apps.py similarity index 92% rename from django_attachments/apps.py rename to drf_attachments/apps.py index 4b872dc..df24e0b 100644 --- a/django_attachments/apps.py +++ b/drf_attachments/apps.py @@ -20,11 +20,11 @@ def create_global_permissions_for_app(sender, **kwargs): class AttachmentsConfig(AppConfig): - name = "django_attachments" + name = "drf_attachments" verbose_name = _("attachments") def ready(self): post_migrate.connect(create_global_permissions_for_app, sender=self) # import signal handlers - import django_attachments.handlers + import drf_attachments.handlers diff --git a/django_attachments/handlers.py b/drf_attachments/handlers.py similarity index 87% rename from django_attachments/handlers.py rename to drf_attachments/handlers.py index 4f0fffd..46df33f 100644 --- a/django_attachments/handlers.py +++ b/drf_attachments/handlers.py @@ -3,7 +3,7 @@ from django.db.models.signals import post_delete from django.dispatch import receiver -from django_attachments.models.models import Attachment +from drf_attachments.models.models import Attachment @receiver(post_delete, sender=Attachment) diff --git a/django_attachments/migrations/0001_initial.py b/drf_attachments/migrations/0001_initial.py similarity index 87% rename from django_attachments/migrations/0001_initial.py rename to drf_attachments/migrations/0001_initial.py index 1fd124b..2113e06 100644 --- a/django_attachments/migrations/0001_initial.py +++ b/drf_attachments/migrations/0001_initial.py @@ -3,7 +3,7 @@ import django.contrib.postgres.fields.jsonb from django.db import migrations, models import django.db.models.deletion -import django_attachments.models.models +import drf_attachments.models.models import uuid @@ -23,7 +23,7 @@ class Migration(migrations.Migration): ('name', models.CharField(blank=True, max_length=255, verbose_name='name')), ('context', models.CharField(blank=True, help_text="Additional info about the attachment's context/meaning.", max_length=255, verbose_name='context')), ('meta', django.contrib.postgres.fields.jsonb.JSONField(help_text='Additional info about the attachment (e.g. file meta data: mime_type, extension, size).', verbose_name='meta')), - ('file', models.FileField(storage=django_attachments.models.models.AttachmentFileStorage(), upload_to=django_attachments.models.models.attachment_upload_path, verbose_name='file')), + ('file', models.FileField(storage=drf_attachments.models.models.AttachmentFileStorage(), upload_to=drf_attachments.models.models.attachment_upload_path, verbose_name='file')), ('object_id', models.UUIDField()), ('creation_date', models.DateTimeField(auto_now_add=True, verbose_name='Creation date')), ('last_modification_date', models.DateTimeField(auto_now=True, verbose_name='Last modification date')), diff --git a/django_attachments/migrations/__init__.py b/drf_attachments/migrations/__init__.py similarity index 100% rename from django_attachments/migrations/__init__.py rename to drf_attachments/migrations/__init__.py diff --git a/django_attachments/models/__init__.py b/drf_attachments/models/__init__.py similarity index 100% rename from django_attachments/models/__init__.py rename to drf_attachments/models/__init__.py diff --git a/django_attachments/models/managers.py b/drf_attachments/models/managers.py similarity index 72% rename from django_attachments/models/managers.py rename to drf_attachments/models/managers.py index eab8beb..79676bf 100644 --- a/django_attachments/models/managers.py +++ b/drf_attachments/models/managers.py @@ -1,4 +1,4 @@ -from django_attachments.models.querysets import AttachmentQuerySet +from drf_attachments.models.querysets import AttachmentQuerySet from django.db import models __all__ = [ diff --git a/django_attachments/models/models.py b/drf_attachments/models/models.py similarity index 98% rename from django_attachments/models/models.py rename to drf_attachments/models/models.py index 41f6399..027baf5 100644 --- a/django_attachments/models/models.py +++ b/drf_attachments/models/models.py @@ -2,8 +2,8 @@ import uuid from uuid import uuid1 -from django_attachments.models.managers import AttachmentManager -from django_attachments.uitls import get_mime_type, get_extension, remove +from drf_attachments.models.managers import AttachmentManager +from drf_attachments.uitls import get_mime_type, get_extension, remove from django.conf import settings from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType @@ -37,7 +37,7 @@ def attachment_upload_path(attachment, filename): NOTE: DO NOT CHANGE THIS METHOD NAME (keep migrations sane). If you ever have to rename/remove this method, you need to mock it (to simply return None) in every migration - that references to django_attachments.models.models.attachment_upload_path + that references to drf_attachments.models.models.attachment_upload_path :param attachment: :param filename: :return: diff --git a/django_attachments/models/querysets.py b/drf_attachments/models/querysets.py similarity index 100% rename from django_attachments/models/querysets.py rename to drf_attachments/models/querysets.py diff --git a/django_attachments/rest/__init__.py b/drf_attachments/rest/__init__.py similarity index 100% rename from django_attachments/rest/__init__.py rename to drf_attachments/rest/__init__.py diff --git a/django_attachments/rest/renderers.py b/drf_attachments/rest/renderers.py similarity index 100% rename from django_attachments/rest/renderers.py rename to drf_attachments/rest/renderers.py diff --git a/django_attachments/rest/serializers.py b/drf_attachments/rest/serializers.py similarity index 96% rename from django_attachments/rest/serializers.py rename to drf_attachments/rest/serializers.py index bb17a08..fd5a7f1 100644 --- a/django_attachments/rest/serializers.py +++ b/drf_attachments/rest/serializers.py @@ -9,7 +9,7 @@ "AttachmentSubSerializer", ] -from django_attachments.models.models import Attachment +from drf_attachments.models.models import Attachment def get_content_object_field(): diff --git a/django_attachments/rest/views.py b/drf_attachments/rest/views.py similarity index 91% rename from django_attachments/rest/views.py rename to drf_attachments/rest/views.py index 81220ce..1b21a5d 100644 --- a/django_attachments/rest/views.py +++ b/drf_attachments/rest/views.py @@ -1,8 +1,8 @@ from rest_framework import viewsets -from django_attachments.models.models import Attachment -from django_attachments.rest.renderers import FileDownloadRenderer -from django_attachments.rest.serializers import AttachmentSerializer +from drf_attachments.models.models import Attachment +from drf_attachments.rest.renderers import FileDownloadRenderer +from drf_attachments.rest.serializers import AttachmentSerializer from django_filters.rest_framework import DjangoFilterBackend from django.http import FileResponse from rest_framework.decorators import action, parser_classes diff --git a/django_attachments/static/attachments/attachment_admin.css b/drf_attachments/static/attachments/attachment_admin.css similarity index 100% rename from django_attachments/static/attachments/attachment_admin.css rename to drf_attachments/static/attachments/attachment_admin.css diff --git a/django_attachments/uitls.py b/drf_attachments/uitls.py similarity index 100% rename from django_attachments/uitls.py rename to drf_attachments/uitls.py diff --git a/setup.py b/setup.py index 137700d..f9b4c1d 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( - name='django-attachments', + name='drf-attachments', version=os.getenv('PACKAGE_VERSION', '0.0.0').replace('refs/tags/', ''), packages=find_packages(), include_package_data=True, @@ -17,7 +17,7 @@ description='A django module to manage any model\'s file up-/downloads by relating an Attachment model to it.', long_description=README, long_description_content_type='text/markdown', - url='https://github.com/anexia-it/django-attachments', + url='https://github.com/anexia-it/drf-attachments', author='Alexandra Bruckner', author_email='abruckner@anexia-it.com', install_requires=[ diff --git a/tests/settings.py b/tests/settings.py index edb49cb..bc9ddb5 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,6 +1,6 @@ """ -Django settings for "tests" project which assures the functionality of the "django-attachments" package -(https://github.com/anexia-it/django-attachments). +Django settings for "tests" project which assures the functionality of the "drf-attachments" package +(https://github.com/anexia-it/drf-attachments). """ import os @@ -30,9 +30,7 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - - # include django-attachments - 'django_attachments', + 'drf_attachments', ] MIDDLEWARE = [