@@ -77,16 +77,30 @@ def _update_entry_name(entry):
77
77
status = status .HTTP_400_BAD_REQUEST ,
78
78
)
79
79
80
+ # Get target Item from ID
80
81
entry = Entry .objects .get (id = sel .validated_data ["id" ])
82
+
83
+ # Check user has permission to update this Item
81
84
if not request .user .has_permission (entry , ACLType .Writable ):
82
85
return Response (
83
86
{"result" : "Permission denied to update entry" },
84
87
status = status .HTTP_400_BAD_REQUEST ,
85
88
)
89
+
90
+ # Abort updating processing when duplicated named Alias exists
91
+ if not sel .validated_data ["entity" ].is_available (
92
+ sel .validated_data ["name" ], [entry .id ]
93
+ ):
94
+ return Response (
95
+ {"result" : "Duplicate named Alias is existed" },
96
+ status = status .HTTP_400_BAD_REQUEST ,
97
+ )
98
+
86
99
will_notify_update_entry = _update_entry_name (entry )
87
100
88
101
elif Entry .objects .filter (** entry_condition ).exists ():
89
102
entry = Entry .objects .get (** entry_condition )
103
+
90
104
if not request .user .has_permission (entry , ACLType .Writable ):
91
105
return Response (
92
106
{"result" : "Permission denied to update entry" },
@@ -95,6 +109,13 @@ def _update_entry_name(entry):
95
109
will_notify_update_entry = _update_entry_name (entry )
96
110
97
111
else :
112
+ # Abort creating Item when duplicated named Alias exists
113
+ if not sel .validated_data ["entity" ].is_available (entry_condition ["name" ]):
114
+ return Response (
115
+ {"result" : "Duplicate named Alias is existed" },
116
+ status = status .HTTP_400_BAD_REQUEST ,
117
+ )
118
+
98
119
# This is the processing just in case for safety not to create duplicate Entries
99
120
# when multiple requests passed through existance check. Even through multiple
100
121
# requests coming here, Django prevents from creating multiple Entries.
0 commit comments