Skip to content

Commit 4d8eb0a

Browse files
authored
feat: allow access to a team's email adresses (#163)
1 parent 7e1abe3 commit 4d8eb0a

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using OrchardCore.ContentManagement;
2+
using OrchardCore.ContentManagement.Display.ContentDisplay;
3+
using OrchardCore.ContentManagement.Display.ViewModels;
4+
using OrchardCore.DisplayManagement.ModelBinding;
5+
using OrchardCore.DisplayManagement.Views;
6+
7+
namespace StatCan.OrchardCore.Hackathon
8+
{
9+
public class HackathonDriver : ContentDisplayDriver
10+
{
11+
public override IDisplayResult Display(ContentItem model, IUpdateModel updater)
12+
{
13+
if (model.ContentType == "Team")
14+
{
15+
// This injects a button on the SummaryAdmin view for the Team ContentType
16+
return Combine(
17+
Shape("Content_SummaryAdmin__Team__Buttons", new ContentItemViewModel(model)).Location("SummaryAdmin", "Actions:9")
18+
);
19+
}
20+
return null;
21+
}
22+
}
23+
}

src/Modules/StatCan.OrchardCore.Hackathon/Indexes/HackathonUsersIndex.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class HackathonUsersIndex : MapIndex
1515
public string UserId { get; set; }
1616
public string UserName { get; set; }
1717
public string Email { get; set; }
18+
public string ContactEmail { get; set; }
1819
public string FirstName { get; set; }
1920
public string LastName { get; set; }
2021
public string Language { get; set; }
@@ -47,6 +48,7 @@ public override void Describe(DescribeContext<User> context)
4748
var hacker = property.ToObject<ContentItem>();
4849
hackathonUsersIndex.FirstName = hacker.Content.ParticipantProfile.FirstName.Text;
4950
hackathonUsersIndex.LastName = hacker.Content.ParticipantProfile.LastName.Text;
51+
hackathonUsersIndex.ContactEmail = hacker.Content.ParticipantProfile.Email.Text;
5052
hackathonUsersIndex.Language = hacker.Content.ParticipantProfile.Language.Text;
5153
}
5254

src/Modules/StatCan.OrchardCore.Hackathon/Indexes/Migrations.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private async void CreateHackathonUsersIndex()
6969
.Column<string>("UserId", c => c.WithLength(26))
7070
.Column<string>("UserName", c => c.WithLength(26))
7171
.Column<string>("Email", c => c.Nullable().WithLength(255))
72+
.Column<string>("ContactEmail", c => c.Nullable().WithLength(255))
7273
.Column<string>("FirstName", c => c.WithLength(26))
7374
.Column<string>("LastName", c => c.WithLength(26))
7475
.Column<string>("Language", c => c.WithLength(4))

src/Modules/StatCan.OrchardCore.Hackathon/Startup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.Extensions.DependencyInjection;
2+
using OrchardCore.ContentManagement.Display.ContentDisplay;
23
using OrchardCore.Data;
34
using OrchardCore.Data.Migration;
45
using OrchardCore.Modules;
@@ -19,6 +20,7 @@ public override void ConfigureServices(IServiceCollection services)
1920

2021
services.AddScoped<IHackathonService, HackathonService>();
2122
services.AddScoped<IDataMigration, HackathonMigrations>();
23+
services.AddScoped<IContentDisplayDriver, HackathonDriver>();
2224
}
2325
}
2426
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% assign teamMembers = Queries.GetHackersForTeam | query: teamContentItemId: Model.ContentItem.ContentItemId %}
2+
<div {% if teamMembers != null %}onclick="select_all_and_copy(document.getElementById('{{Model.ContentItem.ContentItemId}}_emails'))"{%endif%} class="btn btn-primary btn-sm {% if teamMembers == null %}disabled{% endif %}"><i class="fas fa-envelope"></i> {{ "Team" | t }}</div>
3+
<div class="sr-only" id="{{Model.ContentItem.ContentItemId}}_emails">{% for member in teamMembers %}{{ member.ContactEmail }}{% if forloop.last == false %};{% endif%}{% endfor %}</div>
4+
{% script src:'~/OrchardCore.Workflows/Scripts/crossbrowserclipboardcopy.min.js', debug_src:'~/OrchardCore.Workflows/Scripts/crossbrowserclipboardcopy.js', at:"Foot" %}

0 commit comments

Comments
 (0)