def post(self, *args, **kwargs): district_id = self.get_angular_argument('id') new_name = self.get_angular_argument('name') district = District.init_from_district_id(district_id) if not district: self.on_error(**ErrorCodeMessage.district_not_exists) return if not new_name: self.on_error(**ErrorCodeMessage.no_district_name) return if not district.set_name(new_name): self.on_error(**ErrorCodeMessage.database_error) return self.on_success()
def post(self, *args, **kwargs): district_id = self.get_angular_argument('id') action = self.get_angular_argument('action') district = District.init_from_district_id(district_id) if not district: self.on_error(**ErrorCodeMessage.district_not_exists) return if action == 'del': res = district.delete() else: res = district.recover() if res: self.on_success() return self.on_error(**ErrorCodeMessage.database_error)