mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-24 09:08:47 +02:00
Create Matrix room when a Team got created
This commit is contained in:
@ -2,6 +2,7 @@ import os
|
||||
import re
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
from nio import RoomVisibility, RoomPreset
|
||||
|
||||
from corres2math.lists import get_sympa_client
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
@ -14,6 +15,8 @@ from django.utils.crypto import get_random_string
|
||||
from django.utils.text import format_lazy
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from corres2math.matrix import Matrix
|
||||
|
||||
|
||||
class Team(models.Model):
|
||||
name = models.CharField(
|
||||
@ -63,6 +66,13 @@ class Team(models.Model):
|
||||
self.access_code = get_random_string(6)
|
||||
self.create_mailing_list()
|
||||
|
||||
Matrix.create_room(
|
||||
visibility=RoomVisibility.private,
|
||||
alias=f"team-{self.trigram.lower()}",
|
||||
topic=f"Discussion de l'équipe {self.name}",
|
||||
preset=RoomPreset.private_chat,
|
||||
)
|
||||
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
@ -10,4 +10,5 @@ class CustomAuthUser(DjangoAuthUser):
|
||||
d = super().attributs()
|
||||
if self.user:
|
||||
d["matrix_username"] = f"corres2math_{self.user.pk}"
|
||||
d["display_name"] = str(self.user.registration)
|
||||
return d
|
||||
|
@ -1,17 +1,17 @@
|
||||
[
|
||||
{
|
||||
"model": "cas_server.servicepattern",
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"pos": 100,
|
||||
"name": "Plateforme des Correspondances",
|
||||
"pattern": "^https://correspondances-maths.fr:8448/.*$",
|
||||
"user_field": "matrix_username",
|
||||
"restrict_users": false,
|
||||
"proxy": true,
|
||||
"proxy_callback": true,
|
||||
"single_log_out": true,
|
||||
"single_log_out_callback": ""
|
||||
{
|
||||
"model": "cas_server.servicepattern",
|
||||
"pk": 1,
|
||||
"fields": {
|
||||
"pos": 100,
|
||||
"name": "Plateforme des Correspondances",
|
||||
"pattern": "^https://correspondances-maths.fr:8448/.*$",
|
||||
"user_field": "matrix_username",
|
||||
"restrict_users": false,
|
||||
"proxy": true,
|
||||
"proxy_callback": true,
|
||||
"single_log_out": true,
|
||||
"single_log_out_callback": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Reference in New Issue
Block a user