generated from superdesk/newsroom-app
-
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 remote-tracking branch 'origin/uat' into develop
- Loading branch information
Showing
18 changed files
with
257 additions
and
52 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
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,26 +1,36 @@ | ||
import logging | ||
import requests | ||
|
||
from typing import Literal | ||
from flask import current_app as app | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
session = requests.Session() | ||
|
||
|
||
def send_notification(_type, user): | ||
def send_notification(_type, user, id_key: Literal["_id", "email"] = "_id"): | ||
url = app.config.get("CEM_URL", "") | ||
apikey = app.config.get("CEM_APIKEY", "") | ||
if not url or not apikey: | ||
return | ||
headers = {"x-api-key": apikey} | ||
payload = { | ||
"type": _type, | ||
"object_id": str(user["_id"]), | ||
"object_id": str(user[id_key]), | ||
"platform": app.config.get("CEM_PLATFORM"), | ||
} | ||
if user.get("company"): | ||
payload["company"] = str(user["company"]) | ||
session.patch( | ||
url, | ||
timeout=5, | ||
json=payload, | ||
headers=headers, | ||
) | ||
try: | ||
session.patch( | ||
url, | ||
json=payload, | ||
headers=headers, | ||
timeout=int(app.config.get("CEM_TIMEOUT", 10)), | ||
verify=bool(app.config.get("CEM_VERIFY_TLS", True)), | ||
) | ||
except requests.exceptions.RequestException as err: | ||
logger.error(err) | ||
return | ||
logger.info("Notification sent to CEM") |
Empty file.
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,23 @@ | ||
|
||
import time | ||
|
||
from superdesk import get_resource_service | ||
from newsroom.commands.manager import manager | ||
|
||
|
||
@manager.command | ||
def fix_language(resource="items", limit=50, sleep_secs=2): | ||
service = get_resource_service(resource) | ||
|
||
source = {"query": {"terms": {"language": ["en-CA", "en-US", "fr-CA"]}}, "size": 100} | ||
|
||
for i in range(int(limit)): | ||
items = service.search(source) | ||
if not items.count(): | ||
break | ||
for item in items: | ||
updates = {"language": item["language"].split("-")[0]} | ||
service.system_update(item["_id"], updates, item) | ||
print(".", end="", flush=True) | ||
time.sleep(int(sleep_secs)) | ||
print(".") |
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,6 +1,8 @@ | ||
from newsroom.commands import * # noqa | ||
from newsroom.commands.manager import manager | ||
|
||
from cp.commands.fix_language import fix_language # noqa | ||
|
||
|
||
if __name__ == "__main__": | ||
manager.run() |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{%- if item.name %}{{ item.name }} | ||
{% endif %} | ||
{%- if item.dates %}Dates: {{ item.dates.start | datetime_short }} - {{ item.dates.end | datetime_short }} | ||
{% endif %} | ||
{%- if location %}Endroit: {{ location }} | ||
{% endif %} | ||
{%- if item.ednote %}Note de la rédaction: {{ item.ednote }} | ||
{% endif %} | ||
{%- if item.definition_short %}Description: {{ item.definition_short | plain_text }} | ||
{% endif -%} | ||
{%- if item.invitation_details %}Détails de l'invitation: {{ item.invitation_details | plain_text }} | ||
{% endif -%} | ||
{%- if item.registration_details %}Détails de l'inscription: {{ item.registration_details | plain_text }} | ||
{% endif -%} | ||
{%- if contacts | length is gt 0 %} | ||
|
||
Contacts | ||
{%- for contact in contacts %} | ||
Nom: {{ contact.name }} | ||
{% if contact.organisation %}Organisation: {{ contact.organisation }} | ||
{% endif %} | ||
{%- if contact.email %}Courriel: {{ contact.email }} | ||
{% endif %} | ||
{%- if contact.phone %}Téléphone: {{ contact.phone }} | ||
{% endif %} | ||
{%- if contact.mobile %}Mobile: {{ contact.mobile }} | ||
{% endif %} | ||
{%- endfor %} | ||
{%- endif %} | ||
{%- if calendars %} | ||
|
||
Calendriers: {{ calendars }} | ||
{% endif -%} | ||
{%- if item.planning_items | length is gt 0 -%} | ||
{%- for plan in item.planning_items %} | ||
|
||
Élément de couverture | ||
{%- if plan.description_text %} | ||
Description: {{ plan.description_text | plain_text }} | ||
{% endif -%} | ||
{%- for coverage in plan.coverages %} | ||
{% if coverage.planning.g2_content_type %}Type de couverture: {{ coverage.planning.g2_content_type }} | ||
{% endif %} | ||
{%- if coverage.planning.scheduled %}Programmé: {{ coverage.planning.scheduled | datetime_short }} | ||
{% endif %} | ||
{%- if coverage.workflow_status %}Statut: {{ coverage.workflow_status }} | ||
{% endif -%} | ||
{%- if coverage.planning.description_text %}Description: {{ coverage.planning.description_text }} | ||
{% endif -%} | ||
{%- endfor -%} | ||
{%- endfor -%} | ||
{%- endif -%} |
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,8 @@ | ||
{{ item.versioncreated | datetime_short }} | ||
{% if item.slugline %}{{ get_slugline(item, True) }}{% endif %} | ||
{% if item.headline %}{{ item.headline }}{% endif %} | ||
{% if item.byline %}Par: {{ item.byline }}{% endif %} | ||
{% if item.located %}Endroit: {{ item.located }}{% endif %} | ||
{% if item.source %}Source: {{ item.source }}{% endif %} | ||
|
||
{% if item.body_text %}{{ item.body_text }}{% elif item.body_html %}{{ item.body_html | plain_text }}{% endif %} |
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,51 @@ | ||
{% extends "layout_wire.html" %} | ||
|
||
{% block contentMain %} | ||
|
||
<div class="container py-5"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="row"> | ||
<div class="col-md-6 mx-auto"> | ||
<div class="card bg-white"> | ||
<div class="card-header"> | ||
<h3 class="mb-0">{{ gettext("Password Reset") }}</h3> | ||
</div> | ||
<div class="card-body"> | ||
<form class="form" role="form" id="formToken" method="post"> | ||
|
||
{{ form.csrf_token }} | ||
|
||
{% include "form_alerts.html" %} | ||
|
||
<div class="form-group"> | ||
<label for="email">{{ form.email.label.text }}</label> | ||
{{ form.email(class="form-control", id="email", required="true") }} | ||
</div> | ||
|
||
{% if token_type=='validate' %} | ||
<button type="submit" id="reset-btn" class="btn btn-outline-primary ms-3 float-end">{{ gettext("Validate") }}</button> | ||
{% else %} | ||
<button type="submit" id="reset-btn" class="btn btn-outline-primary ms-3 float-end">{{ gettext("Reset Password") }}</button> | ||
{% endif %} | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% include "login_messages.html" %} | ||
|
||
<script> | ||
{% if request.args.get("url") %} | ||
window.nextUrl = "{{ request.args.get("url") }}"; | ||
{% else %} | ||
window.nextUrl = "{{ url_for("auth.login", _external=True) }}"; | ||
{% endif %} | ||
window.externalSuccessUrl = "{{ url_for("cp.auth.reset_password_confirmation", _external=True) }}"; | ||
</script> | ||
|
||
{{ javascript_tag('reset_password') | safe }} | ||
</div> | ||
{% endblock %} |
Binary file not shown.
Oops, something went wrong.