MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / delete

Method delete

web/pgadmin/browser/server_groups/__init__.py:183–236  ·  view source on GitHub ↗

Delete a server group node in the settings database

(self, gid)

Source from the content-addressed store, hash-verified

181
182 @pga_login_required
183 def delete(self, gid):
184 """Delete a server group node in the settings database"""
185
186 groups = ServerGroup.query.filter_by(
187 user_id=current_user.id
188 ).order_by("id")
189
190 # if server group id is 1 we won't delete it.
191 # This matches the behavior of
192 # web/pgadmin/utils/__init.py__#clear_database_servers
193 # called by the setup script when importing and replacing servers:
194 # `python setup.py load-servers input_file.json --replace`
195 sg = groups.first()
196
197 shared_servers = Server.query.filter_by(servergroup_id=gid,
198 shared=True).all()
199 if shared_servers:
200 return make_json_response(
201 status=417,
202 success=0,
203 errormsg=gettext(
204 'The specified server group cannot be deleted.'
205 )
206 )
207
208 if sg.id == gid:
209 return make_json_response(
210 status=417,
211 success=0,
212 errormsg=gettext(
213 'The specified server group cannot be deleted.'
214 )
215 )
216
217 # There can be only one record at most
218 sg = groups.filter_by(id=gid).first()
219
220 if sg is None:
221 return make_json_response(
222 status=410,
223 success=0,
224 errormsg=gettext(SG_NOT_FOUND_ERROR)
225 )
226 else:
227 try:
228 db.session.delete(sg)
229 db.session.commit()
230 except Exception as e:
231 db.session.rollback()
232 return make_json_response(
233 status=410, success=0, errormsg=str(e)
234 )
235
236 return make_json_response(result=request.form)
237
238 @pga_login_required
239 def update(self, gid):

Callers 4

browser.jsFile · 0.45
node.jsFile · 0.45
runTestMethod · 0.45
runTestMethod · 0.45

Calls 3

make_json_responseFunction · 0.90
gettextFunction · 0.85
firstMethod · 0.65

Tested by 2

runTestMethod · 0.36
runTestMethod · 0.36