Coverage for an_website/wiki/wiki.py: 93.333%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-11-16 19:56 +0000

1# This program is free software: you can redistribute it and/or modify 

2# it under the terms of the GNU Affero General Public License as 

3# published by the Free Software Foundation, either version 3 of the 

4# License, or (at your option) any later version. 

5# 

6# This program is distributed in the hope that it will be useful, 

7# but WITHOUT ANY WARRANTY; without even the implied warranty of 

8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

9# GNU Affero General Public License for more details. 

10# 

11# You should have received a copy of the GNU Affero General Public License 

12# along with this program. If not, see <https://www.gnu.org/licenses/>. 

13 

14"""A redirect to an external wiki about the AN.""" 

15 

16from __future__ import annotations 

17 

18from typing import Final 

19 

20from ..utils.request_handler import HTMLRequestHandler 

21from ..utils.utils import ModuleInfo 

22 

23WIKI_URL: Final = "https://wiki.asozial.org" 

24 

25 

26def get_module_info() -> ModuleInfo: 

27 """Create and return the ModuleInfo for this module.""" 

28 return ModuleInfo( 

29 handlers=( 

30 ( 

31 r"/wiki", 

32 WikiHandler, 

33 ), 

34 ), 

35 name="Asoziales Wiki", 

36 description="Ein Wiki mit Sachen des Asozialen Netzwerkes", 

37 path="/wiki", 

38 keywords=( 

39 "Wiki", 

40 "asozial", 

41 ), 

42 ) 

43 

44 

45class WikiHandler(HTMLRequestHandler): 

46 """The request handler for the wiki page.""" 

47 

48 async def get(self, *, head: bool = False) -> None: 

49 """Handle GET requestss to the wiki page.""" 

50 if not self.user_settings.ask_before_leaving: 

51 self.redirect(WIKI_URL) 

52 return 

53 if head: 

54 return 

55 await self.render( 

56 "pages/redirect.html", 

57 send_referrer=True, 

58 redirect_url=WIKI_URL, 

59 from_url=None, 

60 discord=False, 

61 )