mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-12 23:27:22 +00:00
Switch to single quotes
This commit is contained in:
parent
e2a36bb9d9
commit
b54f135a2a
@ -26,12 +26,12 @@ def cli():
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option('--force', '-f', is_flag=True, help="Upload even if it has already been done once.")
|
||||
@click.option('--retry', '-r', is_flag=True, help="Restart automatically after a failure")
|
||||
@click.option('--force', '-f', is_flag=True, help='Upload even if it has already been done once.')
|
||||
@click.option('--retry', '-r', is_flag=True, help='Restart automatically after a failure')
|
||||
@click.option('--batch', type=int, default=1000, show_default=True, metavar='N',
|
||||
help="The amount of records yielded per upload batch.")
|
||||
help='The amount of records yielded per upload batch.')
|
||||
@click.option('--max-size', type=int, metavar='SIZE',
|
||||
help="The max size (in MB) of files to upload. Defaults to the size from the plugin settings.")
|
||||
help='The max size (in MB) of files to upload. Defaults to the size from the plugin settings.')
|
||||
def upload(batch, force, max_size, retry):
|
||||
"""Upload file contents for full text search."""
|
||||
agent = LiveSyncAgent.query.filter(LiveSyncAgent.backend_name == 'citadel').first()
|
||||
|
||||
@ -93,10 +93,10 @@ placeholders = {
|
||||
'person': ('_data.persons_index.name', _("A speaker, author or event chair's name")),
|
||||
'affiliation': ('_data.persons_index.affiliation', _("A speaker, author or event chair's affiliation")),
|
||||
'type': ('type_any', _('An entry type (such as conference, meeting, file, etc.)')),
|
||||
'venue': ('_data.location.venue_name', _("Name of the venue")),
|
||||
'room': ('_data.location.room_name', _("Name of the room")),
|
||||
'address': ('_data.location.address', _("Address of the venue")),
|
||||
'file': ('_data.filename', _("Name of the attached file")),
|
||||
'venue': ('_data.location.venue_name', _('Name of the venue')),
|
||||
'room': ('_data.location.room_name', _('Name of the room')),
|
||||
'address': ('_data.location.address', _('Address of the venue')),
|
||||
'file': ('_data.filename', _('Name of the attached file')),
|
||||
'keyword': ('_data.keywords', _('A keyword associated with an event')),
|
||||
'category': ('category_path.title', _('The category of an event')),
|
||||
}
|
||||
|
||||
@ -62,17 +62,17 @@ def agents():
|
||||
print(table.table)
|
||||
if not all(a.initial_data_exported for a in agent_list):
|
||||
print()
|
||||
print("You need to perform the initial data export for some agents.")
|
||||
print(cformat("To do so, run "
|
||||
"%{yellow!}indico livesync initial-export %{reset}%{yellow}<agent_id>%{reset} for those agents."))
|
||||
print('You need to perform the initial data export for some agents.')
|
||||
print(cformat('To do so, run '
|
||||
'%{yellow!}indico livesync initial-export %{reset}%{yellow}<agent_id>%{reset} for those agents.'))
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument('agent_id', type=int)
|
||||
@click.option('--retry', '-r', is_flag=True, help="Restart automatically after a failure")
|
||||
@click.option('--force', '-f', is_flag=True, help="Perform export even if it has already been done once.")
|
||||
@click.option('--verbose', '-v', is_flag=True, help="Be more verbose (what this does is up to the backend)")
|
||||
@click.option('--batch', type=int, default=5000, help="The amount of records yielded per export batch.",
|
||||
@click.option('--retry', '-r', is_flag=True, help='Restart automatically after a failure')
|
||||
@click.option('--force', '-f', is_flag=True, help='Perform export even if it has already been done once.')
|
||||
@click.option('--verbose', '-v', is_flag=True, help='Be more verbose (what this does is up to the backend)')
|
||||
@click.option('--batch', type=int, default=5000, help='The amount of records yielded per export batch.',
|
||||
show_default=True, metavar='N')
|
||||
def initial_export(agent_id, batch, force, verbose, retry):
|
||||
"""Performs the initial data export for an agent."""
|
||||
@ -116,8 +116,8 @@ def initial_export(agent_id, batch, force, verbose, retry):
|
||||
|
||||
@cli.command()
|
||||
@click.argument('agent_id', type=int, required=False)
|
||||
@click.option('--force', '-f', is_flag=True, help="Run even if initial export was not done")
|
||||
@click.option('--verbose', '-v', is_flag=True, help="Be more verbose (what this does is up to the backend)")
|
||||
@click.option('--force', '-f', is_flag=True, help='Run even if initial export was not done')
|
||||
@click.option('--verbose', '-v', is_flag=True, help='Be more verbose (what this does is up to the backend)')
|
||||
@click.option('--allow-category', '-c', 'allowed_categories', multiple=True, type=int,
|
||||
help="Process changes for the specified category id even if 'Skip category changes' is enabled. "
|
||||
"This setting can be used multiple times.")
|
||||
|
||||
@ -15,4 +15,4 @@ from indico_livesync import _
|
||||
|
||||
class AgentForm(IndicoForm):
|
||||
name = StringField(_('Name'), [DataRequired()],
|
||||
description=_("The name of the agent. Only used in the administration interface."))
|
||||
description=_('The name of the agent. Only used in the administration interface.'))
|
||||
|
||||
@ -23,15 +23,15 @@ from indico_livesync.handler import connect_signals
|
||||
|
||||
class SettingsForm(IndicoForm):
|
||||
queue_entry_ttl = IntegerField(_('Queue entry TTL'), [NumberRange(min=0)],
|
||||
description=_("How many days should processed entries be kept in the queue. "
|
||||
"The time counts from the creation of the queue entries, so if the "
|
||||
"LiveSync task is not running for some time, queue entries may be "
|
||||
"deleted during the next run after processing them. Setting it to 0 "
|
||||
"disables automatic deletion."))
|
||||
description=_('How many days should processed entries be kept in the queue. '
|
||||
'The time counts from the creation of the queue entries, so if the '
|
||||
'LiveSync task is not running for some time, queue entries may be '
|
||||
'deleted during the next run after processing them. Setting it to 0 '
|
||||
'disables automatic deletion.'))
|
||||
excluded_categories = MultipleItemsField(_('Excluded categories'),
|
||||
fields=[{'id': 'id', 'caption': _("Category ID"), 'required': True}],
|
||||
description=_("Changes to objects inside these categories or any of their "
|
||||
"subcategories are excluded."))
|
||||
fields=[{'id': 'id', 'caption': _('Category ID'), 'required': True}],
|
||||
description=_('Changes to objects inside these categories or any of their '
|
||||
'subcategories are excluded.'))
|
||||
disable_queue_runs = BooleanField(_('Disable queue runs'), widget=SwitchWidget(),
|
||||
description=_('Disable all scheduled queue runs.'))
|
||||
skip_category_changes = BooleanField(_('Skip category changes'), widget=SwitchWidget(),
|
||||
|
||||
@ -35,19 +35,19 @@ class EscapablePlaceholder(ParametrizedPlaceholder):
|
||||
|
||||
class FirstNamePlaceholder(EscapablePlaceholder):
|
||||
name = 'first_name'
|
||||
basic_description = _("First name of the registrant")
|
||||
basic_description = _('First name of the registrant')
|
||||
field = 'first_name'
|
||||
|
||||
|
||||
class LastNamePlaceholder(EscapablePlaceholder):
|
||||
name = 'last_name'
|
||||
basic_description = _("Last name of the registrant")
|
||||
basic_description = _('Last name of the registrant')
|
||||
field = 'last_name'
|
||||
|
||||
|
||||
class EmailPlaceholder(EscapablePlaceholder):
|
||||
name = 'email'
|
||||
basic_description = _("Email address of the registrant")
|
||||
basic_description = _('Email address of the registrant')
|
||||
field = 'email'
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ class RegistrationIDPlaceholder(IDPlaceholder):
|
||||
|
||||
class RegistrationDatabaseIDPlaceholder(Placeholder):
|
||||
name = 'registration_db_id'
|
||||
description = _("The database ID of the registration")
|
||||
description = _('The database ID of the registration')
|
||||
|
||||
@classmethod
|
||||
def render(cls, regform, registration):
|
||||
@ -66,7 +66,7 @@ class RegistrationDatabaseIDPlaceholder(Placeholder):
|
||||
|
||||
class RegistrationFormIDPlaceholder(Placeholder):
|
||||
name = 'registration_form_id'
|
||||
description = _("The ID of the registration form")
|
||||
description = _('The ID of the registration form')
|
||||
|
||||
@classmethod
|
||||
def render(cls, regform, registration):
|
||||
@ -75,7 +75,7 @@ class RegistrationFormIDPlaceholder(Placeholder):
|
||||
|
||||
class EventIDPlaceholder(Placeholder):
|
||||
name = 'event_id'
|
||||
description = _("The ID of the event")
|
||||
description = _('The ID of the event')
|
||||
|
||||
@classmethod
|
||||
def render(cls, regform, registration):
|
||||
@ -98,14 +98,14 @@ class PricePlaceholder(ParametrizedPlaceholder):
|
||||
|
||||
@classmethod
|
||||
def iter_param_info(cls, regform, registration):
|
||||
yield None, _("The price the registrant needs to pay (e.g. 100.00 or 100.25)")
|
||||
yield 'short', _("The price without cents if possible (e.g. 100 or 100.25)")
|
||||
yield 'int', _("The price formatted as an integer (e.g. 10000 or 10025)")
|
||||
yield None, _('The price the registrant needs to pay (e.g. 100.00 or 100.25)')
|
||||
yield 'short', _('The price without cents if possible (e.g. 100 or 100.25)')
|
||||
yield 'int', _('The price formatted as an integer (e.g. 10000 or 10025)')
|
||||
|
||||
|
||||
class CurrencyPlaceholder(Placeholder):
|
||||
name = 'currency'
|
||||
description = _("The currency used in the registration")
|
||||
description = _('The currency used in the registration')
|
||||
|
||||
@classmethod
|
||||
def render(cls, regform, registration):
|
||||
|
||||
@ -46,18 +46,18 @@ class RHPaypalIPN(RH):
|
||||
verify_params = list(chain(IPN_VERIFY_EXTRA_PARAMS, request.form.items()))
|
||||
result = requests.post(current_plugin.settings.get('url'), data=verify_params).text
|
||||
if result != 'VERIFIED':
|
||||
current_plugin.logger.warning("Paypal IPN string %s did not validate (%s)", verify_params, result)
|
||||
current_plugin.logger.warning('Paypal IPN string %s did not validate (%s)', verify_params, result)
|
||||
return
|
||||
if self._is_transaction_duplicated():
|
||||
current_plugin.logger.info("Payment not recorded because transaction was duplicated\nData received: %s",
|
||||
current_plugin.logger.info('Payment not recorded because transaction was duplicated\nData received: %s',
|
||||
request.form)
|
||||
return
|
||||
payment_status = request.form.get('payment_status')
|
||||
if payment_status == 'Failed':
|
||||
current_plugin.logger.info("Payment failed (status: %s)\nData received: %s", payment_status, request.form)
|
||||
current_plugin.logger.info('Payment failed (status: %s)\nData received: %s', payment_status, request.form)
|
||||
return
|
||||
if payment_status == 'Refunded' or float(request.form.get('mc_gross')) <= 0:
|
||||
current_plugin.logger.warning("Payment refunded (status: %s)\nData received: %s",
|
||||
current_plugin.logger.warning('Payment refunded (status: %s)\nData received: %s',
|
||||
payment_status, request.form)
|
||||
return
|
||||
if payment_status not in paypal_transaction_action_mapping:
|
||||
@ -79,7 +79,7 @@ class RHPaypalIPN(RH):
|
||||
request.form.get('receiver_email', '').lower()}
|
||||
if expected in candidates:
|
||||
return True
|
||||
current_plugin.logger.warning("Unexpected business: %s not in %r (request data: %r)", expected, candidates,
|
||||
current_plugin.logger.warning('Unexpected business: %s not in %r (request data: %r)', expected, candidates,
|
||||
request.form)
|
||||
return False
|
||||
|
||||
|
||||
@ -15,21 +15,21 @@ from indico_piwik import _
|
||||
|
||||
|
||||
class SettingsForm(IndicoForm):
|
||||
enabled = BooleanField(_("Track global visits"), widget=SwitchWidget())
|
||||
enabled_for_events = BooleanField(_("Track events"), widget=SwitchWidget())
|
||||
cache_enabled = BooleanField(_("Cache results"), widget=SwitchWidget())
|
||||
server_url = StringField(_("Piwik server URL"))
|
||||
server_api_url = StringField(_("Piwik API server URL"),
|
||||
enabled = BooleanField(_('Track global visits'), widget=SwitchWidget())
|
||||
enabled_for_events = BooleanField(_('Track events'), widget=SwitchWidget())
|
||||
cache_enabled = BooleanField(_('Cache results'), widget=SwitchWidget())
|
||||
server_url = StringField(_('Piwik server URL'))
|
||||
server_api_url = StringField(_('Piwik API server URL'),
|
||||
description=_("Should be pointing to 'index.php'"))
|
||||
server_token = StringField(_("Piwik API token"),
|
||||
description=_("Token to access the API. Do not share it!"))
|
||||
site_id_general = StringField(_("Global statistics ID"),
|
||||
description=_("Piwik site ID for global statistics"))
|
||||
site_id_events = StringField(_("Event statistics ID"),
|
||||
description=_("Piwik site ID for event statistics"))
|
||||
cache_ttl = IntegerField(_("Result cache TTL (seconds)"),
|
||||
description=_("How long event reports are kept cached"))
|
||||
use_only_server_url = BooleanField(_("Use Piwik server URL for all requests"))
|
||||
server_token = StringField(_('Piwik API token'),
|
||||
description=_('Token to access the API. Do not share it!'))
|
||||
site_id_general = StringField(_('Global statistics ID'),
|
||||
description=_('Piwik site ID for global statistics'))
|
||||
site_id_events = StringField(_('Event statistics ID'),
|
||||
description=_('Piwik site ID for event statistics'))
|
||||
cache_ttl = IntegerField(_('Result cache TTL (seconds)'),
|
||||
description=_('How long event reports are kept cached'))
|
||||
use_only_server_url = BooleanField(_('Use Piwik server URL for all requests'))
|
||||
|
||||
def validate_site_id_events(self, field):
|
||||
if self.site_id_general is not None and field is not None and self.site_id_general.data == field.data:
|
||||
|
||||
@ -65,9 +65,9 @@ class PiwikRequest:
|
||||
try:
|
||||
response = requests.get(query_url, timeout=timeout)
|
||||
except socket.timeout:
|
||||
current_plugin.logger.warning("Timeout contacting Piwik server")
|
||||
current_plugin.logger.warning('Timeout contacting Piwik server')
|
||||
return default_response
|
||||
except Exception:
|
||||
current_plugin.logger.exception("Unable to connect")
|
||||
current_plugin.logger.exception('Unable to connect')
|
||||
return default_response
|
||||
return response.content
|
||||
|
||||
@ -63,7 +63,7 @@ class PiwikPlugin(IndicoPlugin):
|
||||
def add_sidemenu_item(self, sender, event, **kwargs):
|
||||
if not event.can_manage(session.user) or not PiwikPlugin.settings.get('site_id_events'):
|
||||
return
|
||||
return SideMenuItem('statistics', _("Statistics"), url_for_plugin('piwik.view', event), section='reports')
|
||||
return SideMenuItem('statistics', _('Statistics'), url_for_plugin('piwik.view', event), section='reports')
|
||||
|
||||
def get_blueprints(self):
|
||||
return blueprint
|
||||
|
||||
@ -84,4 +84,4 @@ class PiwikQueryReportEventMetricPeakDateAndVisitors(PiwikQueryReportEventMetric
|
||||
date, value = max(result.items(), key=itemgetter(1))
|
||||
return {'date': date, 'users': value}
|
||||
else:
|
||||
return {'date': "No Data", 'users': 0}
|
||||
return {'date': 'No Data', 'users': 0}
|
||||
|
||||
@ -51,4 +51,4 @@ def stringify_seconds(seconds=0):
|
||||
ti['m'] = minutes % 60
|
||||
ti['h'] = minutes / 60
|
||||
|
||||
return "%dh %dm %ds" % (ti['h'], ti['m'], ti['s'])
|
||||
return '%dh %dm %ds' % (ti['h'], ti['m'], ti['s'])
|
||||
|
||||
@ -51,6 +51,6 @@ class RHEventPreviewIPyNB(RH):
|
||||
response.headers['Content-Security-Policy'] = csp_header
|
||||
response.headers['X-Webkit-CSP'] = csp_header
|
||||
# IE10 doesn't have proper CSP support, so we need to be more strict
|
||||
response.headers['X-Content-Security-Policy'] = "sandbox allow-same-origin;"
|
||||
response.headers['X-Content-Security-Policy'] = 'sandbox allow-same-origin;'
|
||||
|
||||
return response
|
||||
|
||||
@ -34,22 +34,22 @@ class CppHighlighter(Preprocessor):
|
||||
|
||||
# Build regular expressions to catch language extensions or switches and choose
|
||||
# an adequate pygments lexer
|
||||
any_magic = "|".join(self.magics)
|
||||
self.re_magic_language = re.compile(fr"^\s*({any_magic}).*", re.DOTALL)
|
||||
any_magic = '|'.join(self.magics)
|
||||
self.re_magic_language = re.compile(fr'^\s*({any_magic}).*', re.DOTALL)
|
||||
|
||||
def matches(self, source, reg_expr):
|
||||
return bool(reg_expr.match(source))
|
||||
|
||||
def _preprocess_cell_python(self, cell, resources, cell_index):
|
||||
# Mark %%cpp and %%dcl code cells as cpp
|
||||
if cell.cell_type == "code" and self.matches(cell.source, self.re_magic_language):
|
||||
if cell.cell_type == 'code' and self.matches(cell.source, self.re_magic_language):
|
||||
cell['metadata']['magics_language'] = self.cpp
|
||||
|
||||
return cell, resources
|
||||
|
||||
def _preprocess_cell_cpp(self, cell, resources, cell_index):
|
||||
# Mark all code cells as cpp
|
||||
if cell.cell_type == "code":
|
||||
if cell.cell_type == 'code':
|
||||
cell['metadata']['magics_language'] = self.cpp
|
||||
|
||||
return cell, resources
|
||||
@ -57,7 +57,7 @@ class CppHighlighter(Preprocessor):
|
||||
def preprocess(self, nb, resources):
|
||||
self.preprocess_cell = self._preprocess_cell_python
|
||||
try:
|
||||
if nb.metadata.kernelspec.language == "c++":
|
||||
if nb.metadata.kernelspec.language == 'c++':
|
||||
self.preprocess_cell = self._preprocess_cell_cpp
|
||||
except Exception:
|
||||
# if no language metadata, keep python as default
|
||||
|
||||
@ -25,7 +25,7 @@ register_custom_mimetypes()
|
||||
|
||||
|
||||
class NotebookPreviewer(Previewer):
|
||||
ALLOWED_CONTENT_TYPE = re.compile(r"^application/x-ipynb\+json$")
|
||||
ALLOWED_CONTENT_TYPE = re.compile(r'^application/x-ipynb\+json$')
|
||||
|
||||
@classmethod
|
||||
def generate_content(cls, attachment):
|
||||
|
||||
@ -22,8 +22,8 @@ from indico_prometheus.blueprint import blueprint
|
||||
|
||||
class PluginSettingsForm(IndicoForm):
|
||||
enabled = BooleanField(
|
||||
_("Enabled"), [DataRequired()],
|
||||
description=_("Endpoint enabled. Turn this on once you set a proper bearer token."),
|
||||
_('Enabled'), [DataRequired()],
|
||||
description=_('Endpoint enabled. Turn this on once you set a proper bearer token.'),
|
||||
widget=SwitchWidget()
|
||||
)
|
||||
global_cache_ttl = TimeDeltaField(
|
||||
|
||||
@ -30,19 +30,19 @@ from indico_storage_s3.storage import (DynamicS3Storage, ReadOnlyDynamicS3Storag
|
||||
|
||||
|
||||
class SettingsForm(IndicoForm):
|
||||
bucket_info_enabled = BooleanField(_("Bucket info API"), widget=SwitchWidget())
|
||||
username = StringField(_("Username"), [HiddenUnless('bucket_info_enabled', preserve_data=True), DataRequired()],
|
||||
description=_("The username to access the S3 bucket info endpoint"))
|
||||
bucket_info_enabled = BooleanField(_('Bucket info API'), widget=SwitchWidget())
|
||||
username = StringField(_('Username'), [HiddenUnless('bucket_info_enabled', preserve_data=True), DataRequired()],
|
||||
description=_('The username to access the S3 bucket info endpoint'))
|
||||
password = IndicoPasswordField(_('Password'),
|
||||
[HiddenUnless('bucket_info_enabled', preserve_data=True), DataRequired()],
|
||||
toggle=True,
|
||||
description=_("The password to access the S3 bucket info endpoint"))
|
||||
description=_('The password to access the S3 bucket info endpoint'))
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
url = Markup('<strong><code>{}</code></strong>').format(url_for_plugin('storage_s3.buckets'))
|
||||
self.bucket_info_enabled.description = _("Enables an API on {url} that returns information on all S3 buckets "
|
||||
"currently in use, including dynamically-named ones.").format(url=url)
|
||||
self.bucket_info_enabled.description = _('Enables an API on {url} that returns information on all S3 buckets '
|
||||
'currently in use, including dynamically-named ones.').format(url=url)
|
||||
|
||||
|
||||
class S3StoragePlugin(IndicoPlugin):
|
||||
|
||||
@ -34,7 +34,7 @@ class DummyPlugin(VCPluginMixin, IndicoPlugin):
|
||||
configurable = True
|
||||
vc_room_form = VCRoomForm
|
||||
vc_room_attach_form = VCRoomAttachForm
|
||||
friendly_name = "Dummy"
|
||||
friendly_name = 'Dummy'
|
||||
|
||||
@property
|
||||
def logo_url(self):
|
||||
|
||||
@ -59,8 +59,8 @@ class PluginSettingsForm(VCPluginSettingsFormBase):
|
||||
client_secret = IndicoPasswordField(_('Client Secret'), [], toggle=True)
|
||||
|
||||
webhook_token = IndicoPasswordField(_('Webhook Secret Token'), toggle=True,
|
||||
description=_("Specify the \"Secret Token\" of your Zoom Webhook if you want "
|
||||
"live updates in case of modified/deleted Zoom meetings."))
|
||||
description=_('Specify the "Secret Token" of your Zoom Webhook if you want '
|
||||
'live updates in case of modified/deleted Zoom meetings.'))
|
||||
|
||||
user_lookup_mode = IndicoEnumSelectField(_('User lookup mode'), [DataRequired()], enum=UserLookupMode,
|
||||
description=_('Specify how Indico should look up the zoom user that '
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user