# Copyright © 2022 Aravinth Manivannan # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . from urllib.parse import urlparse, urlunparse from django.conf import settings class IssueTracker: """ Hostea support repository Issue tracker URL generation stuff """ def __init__(self): self.config = settings.HOSTEA["META"] self.instance = urlparse(self.config["FORGEJO_INSTANCE"]) self.repo = ( f"{self.config['FORGEJO_ORG_NAME']}/{self.config['SUPPORT_REPOSITORY']}" ) self.issues = f"{self.repo}/issues" def __path(self, path=str): i = self.instance return urlunparse((i.scheme, i.netloc, path, "", "", "")) def get_issue_tracker(self): """ Get issue tracker URL """ return self.__path(path=self.issues) def open_issue(self): """ Get open new issue URL """ path = f"{self.issues}/new" return self.__path(path=path)