diff --git a/src-ui/cypress/fixtures/frontend_settings/settings.json b/src-ui/cypress/fixtures/ui_settings/settings.json similarity index 100% rename from src-ui/cypress/fixtures/frontend_settings/settings.json rename to src-ui/cypress/fixtures/ui_settings/settings.json diff --git a/src-ui/cypress/integration/document-detail.spec.ts b/src-ui/cypress/integration/document-detail.spec.ts index 7083ef582..8faf2412c 100644 --- a/src-ui/cypress/integration/document-detail.spec.ts +++ b/src-ui/cypress/integration/document-detail.spec.ts @@ -2,8 +2,8 @@ describe('document-detail', () => { beforeEach(() => { this.modifiedDocuments = [] - cy.intercept('http://localhost:8000/api/frontend_settings/', { - fixture: 'frontend_settings/settings.json', + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', }) cy.fixture('documents/documents.json').then((documentsJson) => { cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => { diff --git a/src-ui/cypress/integration/documents-list.spec.ts b/src-ui/cypress/integration/documents-list.spec.ts index 45d292fc7..169bd333b 100644 --- a/src-ui/cypress/integration/documents-list.spec.ts +++ b/src-ui/cypress/integration/documents-list.spec.ts @@ -3,8 +3,8 @@ describe('documents-list', () => { this.bulkEdits = {} // mock API methods - cy.intercept('http://localhost:8000/api/frontend_settings/', { - fixture: 'frontend_settings/settings.json', + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', }) cy.fixture('documents/documents.json').then((documentsJson) => { // bulk edit diff --git a/src-ui/cypress/integration/manage.spec.ts b/src-ui/cypress/integration/manage.spec.ts index b098ea6a5..ef7e12723 100644 --- a/src-ui/cypress/integration/manage.spec.ts +++ b/src-ui/cypress/integration/manage.spec.ts @@ -1,7 +1,7 @@ describe('manage', () => { beforeEach(() => { - cy.intercept('http://localhost:8000/api/frontend_settings/', { - fixture: 'frontend_settings/settings.json', + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', }) cy.intercept('http://localhost:8000/api/correspondents/*', { fixture: 'correspondents/correspondents.json', diff --git a/src-ui/cypress/integration/settings.spec.ts b/src-ui/cypress/integration/settings.spec.ts index 8350ae035..16e706b63 100644 --- a/src-ui/cypress/integration/settings.spec.ts +++ b/src-ui/cypress/integration/settings.spec.ts @@ -3,8 +3,8 @@ describe('settings', () => { this.modifiedViews = [] // mock API methods - cy.intercept('http://localhost:8000/api/frontend_settings/', { - fixture: 'frontend_settings/settings.json', + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', }).then(() => { cy.fixture('saved_views/savedviews.json').then((savedViewsJson) => { // saved views PATCH diff --git a/src-ui/src/app/services/settings.service.ts b/src-ui/src/app/services/settings.service.ts index e83ee1415..81b15e1b0 100644 --- a/src-ui/src/app/services/settings.service.ts +++ b/src-ui/src/app/services/settings.service.ts @@ -144,7 +144,7 @@ const SETTINGS: PaperlessSettings[] = [ }) export class SettingsService { private renderer: Renderer2 - protected baseUrl: string = environment.apiBaseUrl + 'frontend_settings/' + protected baseUrl: string = environment.apiBaseUrl + 'ui_settings/' private settings: Object = {} diff --git a/src/documents/migrations/1019_frontendsettings.py b/src/documents/migrations/1019_uisettings.py similarity index 91% rename from src/documents/migrations/1019_frontendsettings.py rename to src/documents/migrations/1019_uisettings.py index 1da17c974..edc944a37 100644 --- a/src/documents/migrations/1019_frontendsettings.py +++ b/src/documents/migrations/1019_uisettings.py @@ -14,7 +14,7 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name="FrontendSettings", + name="UiSettings", fields=[ ( "id", @@ -30,7 +30,7 @@ class Migration(migrations.Migration): "user", models.OneToOneField( on_delete=django.db.models.deletion.CASCADE, - related_name="frontend_settings", + related_name="ui_settings", to=settings.AUTH_USER_MODEL, ), ), diff --git a/src/documents/models.py b/src/documents/models.py index 198bf27b2..208938509 100644 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -470,12 +470,12 @@ class FileInfo: # Extending User Model Using a One-To-One Link -class FrontendSettings(models.Model): +class UiSettings(models.Model): user = models.OneToOneField( User, on_delete=models.CASCADE, - related_name="frontend_settings", + related_name="ui_settings", ) settings = models.JSONField(null=True) @@ -484,6 +484,6 @@ class FrontendSettings(models.Model): @receiver(post_save, sender=User) -def create_user_frontend_settings(sender, instance, created, **kwargs): +def create_user_ui_settings(sender, instance, created, **kwargs): if created: - FrontendSettings.objects.create(user=instance) + UiSettings.objects.create(user=instance) diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index 9119779e8..a26b67e43 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -11,11 +11,11 @@ from . import bulk_edit from .models import Correspondent from .models import Document from .models import DocumentType -from .models import FrontendSettings from .models import MatchingModel from .models import SavedView from .models import SavedViewFilterRule from .models import Tag +from .models import UiSettings from .parsers import is_mime_type_supported @@ -501,9 +501,9 @@ class BulkDownloadSerializer(DocumentListSerializer): }[compression] -class FrontendSettingsViewSerializer(serializers.ModelSerializer): +class UiSettingsViewSerializer(serializers.ModelSerializer): class Meta: - model = FrontendSettings + model = UiSettings depth = 1 fields = [ "id", @@ -511,12 +511,12 @@ class FrontendSettingsViewSerializer(serializers.ModelSerializer): ] def update(self, instance, validated_data): - super(FrontendSettingsViewSerializer, self).update(instance, validated_data) + super(UiSettingsViewSerializer, self).update(instance, validated_data) return instance def create(self, validated_data): - frontend_settings = FrontendSettings.objects.update_or_create( + ui_settings = UiSettings.objects.update_or_create( user=validated_data.get("user"), defaults={"settings": validated_data.get("settings", None)}, ) - return frontend_settings + return ui_settings diff --git a/src/documents/views.py b/src/documents/views.py index 8b548eed7..a47c7c74f 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -71,11 +71,11 @@ from .serialisers import CorrespondentSerializer from .serialisers import DocumentListSerializer from .serialisers import DocumentSerializer from .serialisers import DocumentTypeSerializer -from .serialisers import FrontendSettingsViewSerializer from .serialisers import PostDocumentSerializer from .serialisers import SavedViewSerializer from .serialisers import TagSerializer from .serialisers import TagSerializerVersion1 +from .serialisers import UiSettingsViewSerializer logger = logging.getLogger("paperless.api") @@ -719,10 +719,10 @@ class RemoteVersionView(GenericAPIView): ) -class FrontendSettingsView(GenericAPIView): +class UiSettingsView(GenericAPIView): permission_classes = (IsAuthenticated,) - serializer_class = FrontendSettingsViewSerializer + serializer_class = UiSettingsViewSerializer def get(self, request, format=None): serializer = self.get_serializer(data=request.data) @@ -730,8 +730,8 @@ class FrontendSettingsView(GenericAPIView): user = User.objects.get(pk=request.user.id) settings = [] - if hasattr(user, "frontend_settings"): - settings = user.frontend_settings.settings + if hasattr(user, "ui_settings"): + settings = user.ui_settings.settings return Response( { "user_id": user.id, diff --git a/src/paperless/urls.py b/src/paperless/urls.py index 0ad9d072f..1e41a5979 100644 --- a/src/paperless/urls.py +++ b/src/paperless/urls.py @@ -11,7 +11,6 @@ from documents.views import BulkDownloadView from documents.views import BulkEditView from documents.views import CorrespondentViewSet from documents.views import DocumentTypeViewSet -from documents.views import FrontendSettingsView from documents.views import IndexView from documents.views import LogViewSet from documents.views import PostDocumentView @@ -21,6 +20,7 @@ from documents.views import SearchAutoCompleteView from documents.views import SelectionDataView from documents.views import StatisticsView from documents.views import TagViewSet +from documents.views import UiSettingsView from documents.views import UnifiedSearchViewSet from paperless.consumers import StatusConsumer from paperless.views import FaviconView @@ -80,9 +80,9 @@ urlpatterns = [ name="remoteversion", ), re_path( - r"^frontend_settings/", - FrontendSettingsView.as_view(), - name="frontend_settings", + r"^ui_settings/", + UiSettingsView.as_view(), + name="ui_settings", ), path("token/", views.obtain_auth_token), ]