change respone for service requests

This commit is contained in:
Evgenii Alekseev 2022-11-23 18:19:41 +02:00
parent 89944eb2b6
commit df9e03f495
6 changed files with 18 additions and 12 deletions

View File

@ -4,6 +4,14 @@ ahriman.core.log package
Submodules Submodules
---------- ----------
ahriman.core.log.filtered\_access\_logger module
------------------------------------------------
.. automodule:: ahriman.core.log.filtered_access_logger
:members:
:no-undoc-members:
:show-inheritance:
ahriman.core.log.http\_log\_handler module ahriman.core.log.http\_log\_handler module
------------------------------------------ ------------------------------------------

View File

@ -125,7 +125,6 @@ class Patch(Handler):
package_base(Optional[str]): package base package_base(Optional[str]): package base
variables(List[str]): extract patches only for specified PKGBUILD variables variables(List[str]): extract patches only for specified PKGBUILD variables
exit_code(bool): exit with error on empty search result exit_code(bool): exit with error on empty search result
:
""" """
patches = application.database.patches_list(package_base, variables) patches = application.database.patches_list(package_base, variables)
Patch.check_if_empty(exit_code, not patches) Patch.check_if_empty(exit_code, not patches)

View File

@ -19,8 +19,7 @@
# #
import re import re
from aiohttp.abc import BaseRequest, StreamResponse from aiohttp.web import AccessLogger, BaseRequest, StreamResponse
from aiohttp.web_log import AccessLogger
class FilteredAccessLogger(AccessLogger): class FilteredAccessLogger(AccessLogger):

View File

@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from aiohttp.web import HTTPFound from aiohttp.web import HTTPAccepted
from ahriman.models.user_access import UserAccess from ahriman.models.user_access import UserAccess
from ahriman.web.views.base import BaseView from ahriman.web.views.base import BaseView
@ -44,12 +44,12 @@ class AddView(BaseView):
} }
Raises: Raises:
HTTPAccepted: in case of success response
HTTPBadRequest: if bad data is supplied HTTPBadRequest: if bad data is supplied
HTTPFound: in case of success response
""" """
data = await self.extract_data(["packages"]) data = await self.extract_data(["packages"])
packages = data.get("packages", []) packages = data.get("packages", [])
self.spawner.packages_add(packages, now=True) self.spawner.packages_add(packages, now=True)
raise HTTPFound("/") raise HTTPAccepted()

View File

@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from aiohttp.web import HTTPBadRequest, HTTPFound from aiohttp.web import HTTPAccepted, HTTPBadRequest
from ahriman.models.user_access import UserAccess from ahriman.models.user_access import UserAccess
from ahriman.web.views.base import BaseView from ahriman.web.views.base import BaseView
@ -44,8 +44,8 @@ class RemoveView(BaseView):
} }
Raises: Raises:
HTTPAccepted: in case of success response
HTTPBadRequest: if bad data is supplied HTTPBadRequest: if bad data is supplied
HTTPFound: in case of success response
""" """
try: try:
data = await self.extract_data(["packages"]) data = await self.extract_data(["packages"])
@ -55,4 +55,4 @@ class RemoveView(BaseView):
self.spawner.packages_remove(packages) self.spawner.packages_remove(packages)
raise HTTPFound("/") raise HTTPAccepted()

View File

@ -17,7 +17,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from aiohttp.web import HTTPBadRequest, HTTPFound from aiohttp.web import HTTPAccepted, HTTPBadRequest
from ahriman.models.user_access import UserAccess from ahriman.models.user_access import UserAccess
from ahriman.web.views.base import BaseView from ahriman.web.views.base import BaseView
@ -44,8 +44,8 @@ class RequestView(BaseView):
} }
Raises: Raises:
HTTPAccepted: in case of success response
HTTPBadRequest: if bad data is supplied HTTPBadRequest: if bad data is supplied
HTTPFound: in case of success response
""" """
try: try:
data = await self.extract_data(["packages"]) data = await self.extract_data(["packages"])
@ -55,4 +55,4 @@ class RequestView(BaseView):
self.spawner.packages_add(packages, now=False) self.spawner.packages_add(packages, now=False)
raise HTTPFound("/") raise HTTPAccepted()