Skip to content

Commit b6d3393

Browse files
authored
Merge pull request #800 from ChildMindInstitute/develop
Actualize main
2 parents e82380c + e8fa743 commit b6d3393

14 files changed

Lines changed: 343 additions & 77 deletions

File tree

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ cq:
3737
migrate:
3838
python src/apps/migrate/run.py
3939

40+
.PHONY: migrate_answer
41+
migrate_answer:
42+
python src/apps/migrate/answers/run.py
43+
4044
# ###############
4145
# Docker
4246
# ###############

src/apps/invitations/services.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ async def send_managers_invitation(
389389
try:
390390
await UsersCRUD(self.session).get_by_email(schema.email)
391391
except UserNotFound:
392-
path = "invitation_new_user_en"
392+
path = f"invitation_new_user_{schema.language}"
393393
else:
394-
path = "invitation_registered_user_en"
394+
path = f"invitation_registered_user_{schema.language}"
395395

396396
# Send email to the user
397397
service = MailingService()

src/apps/jsonld_converter/service/document/protocol.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424

2525
class ReproProtocol(LdDocumentBase, ContainsNestedMixin, CommonFieldsMixin):
26-
2726
ld_version: str | None = None
2827
ld_schema_version: str | None = None
2928
ld_pref_label: str | None = None
@@ -111,6 +110,9 @@ async def load(self, doc: dict, base_url: str | None = None):
111110
if rs.get("enabled", False):
112111
self.ld_retention_period = rs.get("period")
113112
self.ld_retention_type = rs.get("retention")
113+
if self.ld_retention_period is not None:
114+
if self.ld_retention_period == 0:
115+
self.ld_retention_period = None
114116

115117
def _get_report_configuration(
116118
self, processed_doc: dict, *, drop=False
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div style="margin-bottom: 30px;border-top: 2px solid rgb(216,216,216);">
2+
<table style="width: 100%">
3+
<tr>
4+
<td style="float: left">
5+
<img
6+
src="https://cmi-logos.s3.amazonaws.com/ChildMindInstitute_Logo_Horizontal_RGB.png"
7+
style="width: 200px; margin-left: 25px;"
8+
alt="Child Mind Institute">
9+
</td>
10+
</tr>
11+
<tr>
12+
<td>
13+
MindLogger de Child Mind Institute n'est pas responsable du contenu créé par des tiers.
14+
</td>
15+
</tr>
16+
</table>
17+
</div>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<html style="max-width: 700px" lang="en">
2+
<body>
3+
{% include 'header.html' %}
4+
<table style="padding: 0">
5+
<tr>
6+
<td style="padding-bottom: 1%">
7+
{{ first_name }}!
8+
</td>
9+
</tr>
10+
<tr>
11+
<td style="padding-bottom: 1%">
12+
Bienvenue dans "{{ applet_name }}"!
13+
</td>
14+
</tr>
15+
<tr>
16+
<td style="padding-bottom: 1%">
17+
Vous avez été invité à devenir {{ role }} de "{{ applet_name
18+
}}", dans l'application MindLogger (voir ci-dessous).
19+
</td>
20+
</tr>
21+
<tr>
22+
<td style="padding-bottom: 1%">
23+
Pour accepter cette invitation, cliquez ci-dessous et votre
24+
navigateur Internet s'ouvrira sur la page d'invitation
25+
de "{{ applet_name }}":
26+
</td>
27+
</tr>
28+
<tr>
29+
<td style="padding-bottom: 1%">
30+
<a
31+
href="{{ link }}/{{ key }}?lang={{ language }}"
32+
style="padding: 0.4rem 1rem; font-size: 0.8rem; line-height: 1.5; border-radius: 0.3rem; margin-left: 100px; display: inline-block; font-weight: 400; text-align: center; vertical-align: middle; text-decoration: none; color: #ffffff; background-color: rgb(88, 217, 65); border-color: rgb(88, 217, 65);"
33+
>
34+
Aller à la page d'invitation "{{ applet_name }}".
35+
</a>
36+
</td>
37+
</tr>
38+
<tr>
39+
<td style="padding-bottom: 1%">
40+
Après avoir accepté l'invitation, vous pourrez accéder à
41+
"{{ applet_name }}" dans l'application gratuite MindLogger sur votre
42+
appareil mobile, en suivant trois étapes simples (voir
43+
<a
44+
href="https://mindlogger.org//guides/user-guide.html"
45+
>
46+
le guide de l'utilisateur
47+
</a>pour plus de détails):
48+
</td>
49+
</tr>
50+
<tr>
51+
<td style="padding-bottom: 1%">
52+
<ol>
53+
<li>
54+
Installez l'application MindLogger sur votre appareil
55+
mobile, si elle n'est pas déjà installée.
56+
</li>
57+
<li>
58+
Ouvrez l'application MindLogger sur votre appareil mobile et
59+
connectez-vous (si vous avez un compte MindLogger) ou
60+
inscrivez-vous (si vous êtes nouveau sur MindLogger).
61+
Pour vous inscrire, appuyez sur "Nouvel utilisateur" sur
62+
l'écran de connexion et entrez l'adresse email à laquelle
63+
vous avez reçu l'invitation.
64+
</li>
65+
<li>
66+
Appuyez sur "{{ applet_name }}" sur l'écran d'accueil de
67+
MindLogger et vous êtes prêt ! Si "{{ applet_name }}"
68+
n'apparaît pas, rafraîchissez l'écran en faisant glisser
69+
votre doigt vers le bas à partir du haut, et une roue
70+
devrait apparaître pendant le chargement
71+
de "{{ applet_name }}".
72+
</li>
73+
</ol>
74+
</td>
75+
</tr>
76+
<tr>
77+
<td style="padding-bottom: 1%">
78+
Merci d'avoir accepté l'invitation à utiliser "{{ applet_name }}"!
79+
</td>
80+
</tr>
81+
<tr>
82+
<td style="padding-bottom: 1%">
83+
-L'équipe MindLogger
84+
</td>
85+
</tr>
86+
</table>
87+
{% include 'footers/footer_info_fr.html' %}
88+
</body>
89+
90+
</html>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<html style="max-width: 700px" lang="en">
2+
<body>
3+
{% include 'header.html' %}
4+
<table style="padding: 0">
5+
<tr>
6+
<td style="padding-bottom: 1%">
7+
{{ first_name }}!
8+
</td>
9+
</tr>
10+
<tr>
11+
<td style="padding-bottom: 1%">
12+
Bienvenue dans "{{ applet_name }}"!
13+
</td>
14+
</tr>
15+
<tr>
16+
<td style="padding-bottom: 1%">
17+
Vous avez été invité à devenir {{ role }} de "{{ applet_name
18+
}}", dans l'application MindLogger (voir ci-dessous).
19+
</td>
20+
</tr>
21+
<tr>
22+
<td style="padding-bottom: 1%">
23+
Pour accepter cette invitation, cliquez ci-dessous et votre
24+
navigateur Internet s'ouvrira sur la page d'invitation
25+
de "{{ applet_name }}":
26+
</td>
27+
</tr>
28+
<tr>
29+
<td style="padding-bottom: 1%">
30+
<a
31+
href="{{ link }}/{{ key }}?lang={{ language }}"
32+
style="padding: 0.4rem 1rem; font-size: 0.8rem; line-height: 1.5; border-radius: 0.3rem; margin-left: 100px; display: inline-block; font-weight: 400; text-align: center; vertical-align: middle; text-decoration: none; color: #ffffff; background-color: rgb(88, 217, 65); border-color: rgb(88, 217, 65);"
33+
>
34+
Aller à la page d'invitation "{{ applet_name }}".
35+
</a>
36+
</td>
37+
</tr>
38+
<tr>
39+
<td style="padding-bottom: 1%">
40+
Après avoir accepté l'invitation, vous pourrez accéder à
41+
"{{ applet_name }}" dans l'application gratuite MindLogger sur votre
42+
appareil mobile, en suivant trois étapes simples (voir
43+
<a
44+
href="https://mindlogger.org//guides/user-guide.html"
45+
>
46+
le guide de l'utilisateur
47+
</a>pour plus de détails):
48+
</td>
49+
</tr>
50+
<tr>
51+
<td style="padding-bottom: 1%">
52+
<ol>
53+
<li>
54+
Installez l'application MindLogger sur votre appareil
55+
mobile, si elle n'est pas déjà installée.
56+
</li>
57+
<li>
58+
Ouvrez l'application MindLogger sur votre appareil mobile et
59+
connectez-vous.
60+
</li>
61+
<li>
62+
Appuyez sur "{{ applet_name }}" sur l'écran d'accueil de
63+
MindLogger et c'est tout ! Si "{{ applet_name }}"
64+
n'apparaît pas, rafraîchissez l'écran en faisant glisser
65+
votre doigt vers le bas à partir du haut et une roue
66+
devrait apparaître pendant le chargement
67+
de "{{ applet_name }}".
68+
</li>
69+
</ol>
70+
</td>
71+
</tr>
72+
<tr>
73+
<td style="padding-bottom: 1%">
74+
Merci d'avoir accepté l'invitation à utiliser "{{ applet_name }}"!
75+
</td>
76+
</tr>
77+
<tr>
78+
<td style="padding-bottom: 1%">
79+
-L'équipe MindLogger
80+
</td>
81+
</tr>
82+
</table>
83+
{% include 'footers/footer_info_fr.html' %}
84+
</body>
85+
86+
</html>

src/apps/migrate/answers/answer_item_service.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,19 @@ def _get_item_ids(self, mongo_answer):
7474
for k in list(mongo_answer["meta"]["responses"])
7575
]
7676

77+
item_ids_from_url = [url.split("/")[-1] for url in responses_keys]
7778
return [
7879
str(mongoid_to_uuid(i["_id"]))
7980
for i in Item().find(
8081
query={
8182
"meta.activityId": mongo_answer["meta"]["activity"]["@id"],
82-
"meta.screen.schema:url": {"$in": responses_keys},
83+
# If meta.screen.schema:url exists then try to find by url,
84+
# because meta.screen.@id will start with '/'.
85+
# In other case try to find by last word in url (screen.@id)
86+
"$or": [
87+
{"meta.screen.@id": {"$in": item_ids_from_url}},
88+
{"meta.screen.schema:url": {"$in": responses_keys}},
89+
],
8390
}
8491
)
8592
]

src/apps/migrate/answers/run.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,31 @@
3939
)
4040

4141

42+
APPLETS_WITH_ISSUES_DONT_MIGRATE_ANSWERS = {
43+
"623cd7ee5197b9338bdaf218",
44+
"6116c49e66f506a576da4f03",
45+
"5fd28283c47c585b7c73354b",
46+
"5f0e35523477de8b4a528dd0",
47+
"61f3415f62485608c74c1f0b",
48+
"61f3423962485608c74c1f45",
49+
"623cb24d5197b9338bdaed65",
50+
"623ce1695197b9338bdaf388",
51+
"61f3419a62485608c74c1f25",
52+
"63d3d579b71996780cdf409a",
53+
"636533965cb70043112200a9",
54+
"636936b352ea02101467640d",
55+
"631aba1db7ee970ffa9009e3",
56+
"623ce52a5197b9338bdaf4b6",
57+
"623dfaf95197b9338bdaf8c5",
58+
"62f16366acd35a39e99b57ec",
59+
"636425cf5cb700431121fe46",
60+
"636532fd5cb700431121ff93",
61+
"636936ca52ea021014676437",
62+
"636936e652ea02101467645b",
63+
"636e942c52ea0234e1f4ec25",
64+
}
65+
66+
4267
class AnswersMigrateFacade:
4368
anonymous_respondent_answers = 0
4469
total_answers = 0
@@ -57,7 +82,11 @@ async def migrate(self, workspace, applets):
5782
regular_session = session_manager.get_session()
5883

5984
applets_ids = await self._get_allowed_applets_ids(workspace, applets)
60-
applets_ids = [mongoid_to_uuid(applet_id) for applet_id in applets_ids]
85+
applets_ids = [
86+
mongoid_to_uuid(applet_id)
87+
for applet_id in applets_ids
88+
if applet_id not in APPLETS_WITH_ISSUES_DONT_MIGRATE_ANSWERS
89+
]
6190

6291
await self._wipe_answers_data(regular_session, applets_ids)
6392

src/apps/migrate/data_description/library_dao.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def values(self) -> tuple:
4343
class ThemeDao:
4444
id: uuid.UUID
4545
creator_id: uuid.UUID
46-
applet_id: uuid.UUID
4746
name: str
4847
logo: str | None
4948
small_logo: str | None

src/apps/migrate/run.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,13 @@ def migrate_user_pins(
649649
skipped += 1
650650
continue
651651
to_migrate.append(profile)
652-
rows_count = postgres.save_user_pins(to_migrate)
653-
migration_log.info(f"Inserted {rows_count} rows")
654-
migration_log.info("User pins migration end")
652+
try:
653+
rows_count = postgres.save_user_pins(to_migrate)
654+
migration_log.info(f"Inserted {rows_count} rows")
655+
except Exception as e:
656+
migration_log.error(e)
657+
finally:
658+
migration_log.info("User pins migration end")
655659

656660

657661
def migrate_folders(workspace_id: str | None, mongo, postgres):
@@ -677,7 +681,8 @@ def migrate_library(
677681
migration_log.info("Library & themes migration start")
678682
lib_count = 0
679683
theme_count = 0
680-
lib_set, theme_set = mongo.get_library(applet_ids)
684+
lib_set = mongo.get_library(applet_ids)
685+
theme_set = mongo.get_themes()
681686
for lib in lib_set:
682687
if lib.applet_id_version is None:
683688
version = postgres.get_latest_applet_id_version(lib.applet_id)
@@ -701,7 +706,7 @@ def migrate_library(
701706
success = postgres.save_theme_item(theme)
702707
if success:
703708
theme_count += 1
704-
postgres.add_theme_to_applet(theme.applet_id, theme.id)
709+
# postgres.add_theme_to_applet(theme.applet_id, theme.id)
705710

706711
applet_themes = mongo.get_applet_theme_mapping()
707712
applets_count = postgres.set_applets_themes(applet_themes)
@@ -842,7 +847,7 @@ async def migrate_public_links(postgres: Postgres, mongo: Mongo):
842847
applet_mongo_ids = postgres.get_migrated_applets()
843848
links = mongo.get_public_link_mappings(applet_mongo_ids)
844849
await postgres.save_public_link(links)
845-
migration_log.info("Public links migration start")
850+
migration_log.info("Public links migration end")
846851

847852

848853
async def main(workspace_id: str | None, applets_ids: list[str] | None):

0 commit comments

Comments
 (0)