Skip to content

Commit

Permalink
Merge pull request #970 from betagouv/feat/add-info-collab
Browse files Browse the repository at this point in the history
Feat/add info collab
  • Loading branch information
glibersat authored Feb 10, 2025
2 parents 64ee41b + ea57d74 commit 7e59cf2
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
describe('I can go to a project and see if the main collaborator has accepted the invitation', () => {

it('can see if the main colloborator has accepted the invitation or not', () => {
cy.login('jean');
cy.visit('/project/27/presentation');
cy.get('[data-test-id="invite-not-accepted-banner"]').should('exist');

cy.visit('/project/23/presentation');
cy.get('[data-test-id="invite-not-accepted-banner"]').should('not.exist');
});
});
14 changes: 14 additions & 0 deletions frontend_tests/cypress/fixtures/projects/invites.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,19 @@
"project_id": 26,
"site_id": 1
}
},
{
"model": "invites.invite",
"pk": "e6f6e766-5e64-4bae-965d-1ce551cf659a",
"fields": {
"created_on": "2025-01-29T14:31:39Z",
"accepted_on": null,
"email": "[email protected]",
"message": "viens donc référer ce projet",
"role": "COLLABORATOR",
"inviter_id": 2,
"project_id": 28,
"site_id": 1
}
}
]
28 changes: 28 additions & 0 deletions frontend_tests/cypress/fixtures/projects/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -745,5 +745,33 @@
"deleted": null,
"sites": [1]
}
},
{
"model": "projects.project",
"pk": 28,
"fields": {
"submitted_by": 2,
"ro_key": "427c0b01b71f49ea8878f52ec14ad80e",
"last_name": "Inviteur",
"first_name": "Conseiller",
"publish_to_cartofriches": false,
"exclude_stats": true,
"muted": false,
"org_name": "testing world company",
"created_on": "2025-01-29T14:31:39Z",
"updated_on": "2025-01-19T13:08:07.795Z",
"tags": "",
"name": "test referant pas accepter invite",
"phone": "01 01 01 01 01",
"description": "projet dont le referant est invité mais n'a pas accepté l'invitation",
"advisors_note": "j'ai créé le projet pour vous",
"advisors_note_on": "2025-01-29T14:51:12Z",
"advisors_note_by": 2,
"location": "91 rue du test",
"commune": 3,
"impediments": "",
"deleted": null,
"sites": [1]
}
}
]
9 changes: 9 additions & 0 deletions frontend_tests/cypress/fixtures/projects/projectsMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@
"is_owner": true
}
},
{
"model": "projects.projectmember",
"pk": 21,
"fields": {
"member": 5,
"project": 28,
"is_owner": true
}
},
{
"model": "projects.projectswitchtender",
"pk": 1,
Expand Down
10 changes: 10 additions & 0 deletions frontend_tests/cypress/fixtures/projects/projectsSites.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,15 @@
"project_id": 27,
"site_id": 1
}
},
{
"pk": 31,
"model": "projects.projectsite",
"fields": {
"status": "TO_PROCESS",
"is_origin": true,
"project_id": 28,
"site_id": 1
}
}
]
3 changes: 2 additions & 1 deletion recoco/apps/invites/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@


class InviteManager(models.Manager):
pass
def pending(self):
return self.filter(accepted_on=None)


class InviteOnSiteManager(CurrentSiteManager, InviteManager):
Expand Down
29 changes: 29 additions & 0 deletions recoco/apps/invites/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,4 +693,33 @@ def test_logged_in_user_accepts_invite_but_is_already_advisor(
assert user not in invite.project.members.all()


# Managers
@pytest.mark.django_db
def test_manager_active_filter(request, project):
current_site = get_current_site(request)

pending_invite = baker.make(
models.Invite,
role="COLLABORATOR",
accepted_on=None,
site=current_site,
project=project,
email="[email protected]",
)

baker.make(
models.Invite,
role="COLLABORATOR",
accepted_on=timezone.now(),
site=current_site,
project=project,
email="[email protected]",
)

assert models.Invite.objects.count() == 2
assert models.Invite.objects.pending().count() == 1

assert models.Invite.objects.pending().first() == pending_invite


# eof
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.invite-not-accepted-banner {
background-color: #FFE8E5;
&__span {
color: #B34000;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ <h6 class="text-uppercase fw-bold d-block fr-mb-2w h6-specific-fontsize-14">Part
{% if pm.member.is_active %}
{% if pm.is_owner %}
<li>{% include "user/user_card.html" with user=pm.member project_owner=True user_activity=True %}</li>
<li>
{% include "projects/project/fragments/owner/invite-not-accepted-banner.html" with invites=project.invites.pending %}
</li>
{% else %}
<li>{% include "user/user_card.html" with user=pm.member user_activity=True %}</li>
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% load sass_tags %}
{% block css %}
<link href="{% sass_src 'projects/css/fragments/owner/invite-not-accepted-banner.scss' %}"
rel="stylesheet"
type="text/css">
{% endblock css %}
{% if project.owner != project.submitted_by %}
{% for invite in invites %}
{% if invite.role == "COLLABORATOR" and invite.email == project.owner.email %}
<div class="invite-not-accepted-banner fr-p-2v"
data-test-id="invite-not-accepted-banner">
<span class="fr-icon-warning-line invite-not-accepted-banner__span fr-mx-2v"
aria-hidden="true"></span><span class="invite-not-accepted-banner__span">Cette personne n’a pas encore rejoint le projet</span>
</div>
{% endif %}
{% endfor %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ <h6 class="text-uppercase fw-bold d-block fr-mb-1v lh-base h6-specific-fontsize-
<h6 class="text-uppercase fw-bold d-block fr-mb-2w h6-specific-fontsize-14">Référent porteur de projet</h6>
{% include "projects/project/fragments/project_owner.html" with project=project %}
{% include "projects/project/fragments/owner/owner-details.html" with project=project %}
{% include "projects/project/fragments/owner/invite-not-accepted-banner.html" with invites=project.invites.pending %}
</div>
</div>
<!-- User lists -->
Expand Down

0 comments on commit 7e59cf2

Please sign in to comment.