mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Owner/name unique constraint violation should exclude self
This commit is contained in:
		@@ -1505,7 +1505,7 @@
 | 
			
		||||
        </context-group>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">208</context>
 | 
			
		||||
          <context context-type="linenumber">213</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/settings/settings.component.html</context>
 | 
			
		||||
@@ -2700,7 +2700,7 @@
 | 
			
		||||
        </context-group>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">204</context>
 | 
			
		||||
          <context context-type="linenumber">209</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="5382975254277698192" datatype="html">
 | 
			
		||||
@@ -3817,36 +3817,39 @@
 | 
			
		||||
          <context context-type="linenumber">147</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="6151710751857751783" datatype="html">
 | 
			
		||||
        <source>Error occurred while saving <x id="PH" equiv-text="this.typeName"/> : <x id="PH_1" equiv-text="activeModal.componentInstance.error"/>.</source>
 | 
			
		||||
      <trans-unit id="1370653329436185913" datatype="html">
 | 
			
		||||
        <source>Error occurred while saving <x id="PH" equiv-text="this.typeName"/><x id="PH_1" equiv-text="errorDetail ? ': ' + errorDetail : ''"/>.</source>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">171</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">182,184</context>
 | 
			
		||||
          <context context-type="linenumber">174,176</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="2541368547549828690" datatype="html">
 | 
			
		||||
        <source>Successfully updated <x id="PH" equiv-text="this.typeName"/>.</source>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">176</context>
 | 
			
		||||
          <context context-type="linenumber">181</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="6151710751857751783" datatype="html">
 | 
			
		||||
        <source>Error occurred while saving <x id="PH" equiv-text="this.typeName"/> : <x id="PH_1" equiv-text="e.toString()"/>.</source>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">187,189</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="4012132330507560812" datatype="html">
 | 
			
		||||
        <source>Do you really want to delete the <x id="PH" equiv-text="this.typeName"/>?</source>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">191</context>
 | 
			
		||||
          <context context-type="linenumber">196</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="8371896857609524947" datatype="html">
 | 
			
		||||
        <source>Associated documents will not be deleted.</source>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">206</context>
 | 
			
		||||
          <context context-type="linenumber">211</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="5467489005440577210" datatype="html">
 | 
			
		||||
@@ -3855,7 +3858,7 @@
 | 
			
		||||
            )"/></source>
 | 
			
		||||
        <context-group purpose="location">
 | 
			
		||||
          <context context-type="sourcefile">src/app/components/manage/management-list/management-list.component.ts</context>
 | 
			
		||||
          <context context-type="linenumber">219,221</context>
 | 
			
		||||
          <context context-type="linenumber">224,226</context>
 | 
			
		||||
        </context-group>
 | 
			
		||||
      </trans-unit>
 | 
			
		||||
      <trans-unit id="1685061484835793745" datatype="html">
 | 
			
		||||
 
 | 
			
		||||
@@ -167,8 +167,13 @@ export abstract class ManagementListComponent<T extends ObjectWithId>
 | 
			
		||||
    activeModal.componentInstance.succeeded.subscribe({
 | 
			
		||||
      next: () => {
 | 
			
		||||
        if (activeModal.componentInstance.error) {
 | 
			
		||||
          const errorDetail = activeModal.componentInstance.error.error
 | 
			
		||||
            ? activeModal.componentInstance.error.error[0]
 | 
			
		||||
            : null
 | 
			
		||||
          this.toastService.showInfo(
 | 
			
		||||
            $localize`Error occurred while saving ${this.typeName} : ${activeModal.componentInstance.error}.`
 | 
			
		||||
            $localize`Error occurred while saving ${this.typeName}${
 | 
			
		||||
              errorDetail ? ': ' + errorDetail : ''
 | 
			
		||||
            }.`
 | 
			
		||||
          )
 | 
			
		||||
        } else {
 | 
			
		||||
          this.reloadData()
 | 
			
		||||
 
 | 
			
		||||
@@ -78,10 +78,11 @@ class MatchingModelSerializer(serializers.ModelSerializer):
 | 
			
		||||
            if hasattr(self, "user")
 | 
			
		||||
            else None
 | 
			
		||||
        )
 | 
			
		||||
        pk = self.instance.pk if hasattr(self.instance, "pk") else None
 | 
			
		||||
        if ("name" in data or "owner" in data) and self.Meta.model.objects.filter(
 | 
			
		||||
            name=name,
 | 
			
		||||
            owner=owner,
 | 
			
		||||
        ).exists():
 | 
			
		||||
        ).exclude(pk=pk).exists():
 | 
			
		||||
            raise serializers.ValidationError(
 | 
			
		||||
                {"error": "Object violates owner / name unique constraint"},
 | 
			
		||||
            )
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user