This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from RaenonX/dev
Pre-webhook release - Added beta/stable release time in About page.
- Loading branch information
Showing
78 changed files
with
1,135 additions
and
13,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,4 @@ | |
.idea/ | ||
__pycache__/ | ||
lib/ | ||
node_modules/ | ||
staticfiles/ | ||
*.bat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from JellyBotAPI.api.static import param | ||
from JellyBotAPI.api.responses import ( | ||
PermissionQueryResponse | ||
) | ||
from JellyBotAPI.components.mixin import CsrfExemptMixin, CheckParameterMixin, APIStatisticsCollectMixin | ||
from JellyBotAPI.components.views import APIJsonResponseView | ||
from flags import APICommand | ||
|
||
|
||
class PermissionQueryView(CsrfExemptMixin, APIStatisticsCollectMixin, CheckParameterMixin, APIJsonResponseView): | ||
get_response_class = PermissionQueryResponse | ||
|
||
def get_api_action(self): | ||
return APICommand.DATA_PERMISSION | ||
|
||
def mandatory_keys(self) -> set: | ||
return {param.Manage.Channel.CHANNEL_OID} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from django.urls import path | ||
|
||
from .channel import ChannelDataQueryView, ChannelIssueRegistrationTokenView, ChannelNameChangeView | ||
from .perm import PermissionQueryView | ||
|
||
urlpatterns = [ | ||
path('ch/data', ChannelDataQueryView.as_view(), name='api.id.channel.data'), | ||
path('ch/reg/issue', ChannelIssueRegistrationTokenView.as_view(), name='api.id.channel.register_token'), | ||
path('ch/name-change', ChannelNameChangeView.as_view(), name='api.id.channel.name_change') | ||
path('ch/name-change', ChannelNameChangeView.as_view(), name='api.id.channel.name_change'), | ||
path('perm', PermissionQueryView.as_view(), name='api.id.perm') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .channel import ChannelDataQueryResponse, ChannelIssueRegisterTokenResponse, ChannelNameChangeResponse | ||
from .perm import PermissionQueryResponse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from JellyBotAPI.api.responses import BaseApiResponse | ||
from JellyBotAPI.api.static import param | ||
from JellyBotAPI.api.responses.mixin import ( | ||
RequireSenderMixin, | ||
SerializeErrorMixin, SerializeResultOnSuccessMixin, SerializeResultExtraMixin | ||
) | ||
from mongodb.factory import ProfileManager | ||
|
||
|
||
class PermissionQueryResponse( | ||
RequireSenderMixin, | ||
SerializeErrorMixin, SerializeResultOnSuccessMixin, SerializeResultExtraMixin, BaseApiResponse): | ||
def __init__(self, param_dict, sender_oid): | ||
super().__init__(param_dict, sender_oid) | ||
|
||
self._param_dict.update(**{ | ||
param.Manage.USER_OID: sender_oid, | ||
param.Manage.Channel.CHANNEL_OID: param_dict.get(param.Manage.Channel.CHANNEL_OID), | ||
}) | ||
|
||
self._root_oid = sender_oid | ||
self._channel_oid = self._param_dict[param.Manage.Channel.CHANNEL_OID] | ||
self._profiles = None | ||
|
||
def _handle_channel_(self): | ||
if not self._channel_oid: | ||
self._err[param.Manage.Channel.CHANNEL_OID] = self._channel_oid | ||
|
||
def pre_process(self): | ||
super().pre_process() | ||
|
||
self._handle_channel_() | ||
|
||
def pass_condition(self) -> bool: | ||
return super().pass_condition() and self._channel_oid is not None and self._root_oid is not None | ||
|
||
def is_success(self) -> bool: | ||
return super().is_success() and self._profiles is not None | ||
|
||
def process_pass(self): | ||
self._profiles = ProfileManager.get_user_profiles(self._channel_oid, self._root_oid) | ||
|
||
if self._profiles: | ||
self._result = ProfileManager.get_permissions(self._profiles) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
from dateutil import parser | ||
|
||
from django.utils.timezone import localtime | ||
from django.views.generic.base import View | ||
from django.utils.translation import gettext as _ | ||
|
||
from JellyBotAPI.views.render import render_template | ||
from extutils import HerokuWrapper, GithubWrapper | ||
|
||
|
||
class AboutView(View): | ||
# noinspection PyUnusedLocal, PyMethodMayBeStatic | ||
def get(self, request, *args, **kwargs): | ||
return render_template(request, _("About"), "about.html") | ||
beta_app = "jellybotapi-staging" | ||
stable_app = "jellybotapi" | ||
|
||
return render_template(request, _("About"), "about.html", { | ||
"beta_update_about": localtime( | ||
HerokuWrapper.latest_succeeded_release(beta_app).updated_at).strftime("%m/%d %H:%M:%S (UTC%z)"), | ||
"stable_update_about": localtime( | ||
HerokuWrapper.latest_succeeded_release(stable_app).updated_at).strftime("%m/%d %H:%M:%S (UTC%z)"), | ||
"beta_deploy": localtime( | ||
parser.parse( | ||
GithubWrapper.get_latest_deployment(beta_app).updated_at)).strftime("%m/%d %H:%M:%S (UTC%z)"), | ||
"stable_deploy": localtime( | ||
parser.parse( | ||
GithubWrapper.get_latest_deployment(stable_app).updated_at)).strftime("%m/%d %H:%M:%S (UTC%z)") | ||
}) |
Oops, something went wrong.