My Involvement Widget

The My Involvement widget displays links to every organization in which the user is currently enrolled.

The widget utilizes an HTML file, SQL script and Python script as shown below. Since the involvement list is different for each user, Caching should be set to each user.

HTML Code

Below is the HTML code for the My Involvement widget. As supplied by TouchPoint, the file name is WidgetInvolvementHTML.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<div class="box">
    <div class="box-title hidden-xs">
        <h5><a href="/Person2/{{CurrentPerson.PeopleId}}#enrollment">{{WidgetName}}</a></h5>
    </div>
    <a class="visible-xs-block" id="{{WidgetId}}-collapse" data-toggle="collapse" href="#{{WidgetId}}-section" aria-expanded="true" aria-controls="{{WidgetId}}-section">
        <div class="box-title">
            <h5>
                <i class="fa fa-chevron-circle-right"></i>&nbsp;&nbsp;{{WidgetName}}
            </h5>
            {{#ifGT results.Count 0}}
                <div class="pull-right">
                    <span class="badge badge-primary">{{results.Count}}</span>
                </div>
            {{/ifGT}}
        </div>
    </a>
    <div class="collapse in" id="{{WidgetId}}-section">
        {{#ifGT results.Count 0}}
            <ul class="list-group">
                {{#each results}}
                    {{#ifEqual New "New"}}
                        <li class="list-group-item section">{{Description}}</li>
                    {{/ifEqual}}
                    <li class="list-group-item indent"><a href="/Org/{{OrganizationId}}">{{OrganizationName}}</a></li>
                {{/each}}
            </ul>
        {{else}}
            <div class="box-content"></div>
        {{/ifGT}}
    </div>
</div>

SQL Script

Below is the SQL script for the My Involvement widget. As supplied by TouchPoint, the file name is WidgetInvolvementSQL.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
select org.OrganizationName, om.OrganizationId, ISNULL(ot.Description, 'Other') as Description from OrganizationMembers om
join Organizations org on om.OrganizationId = org.OrganizationId
left join lookup.OrganizationType ot on org.OrganizationTypeId = ot.Id
left join lookup.MemberType mt on om.MemberTypeId = mt.Id
where om.PeopleId = @pid
and om.Pending != 1
and org.SecurityTypeId != 3
and isnull(org.LimitToRole, 'Access') in (select RoleName from dbo.Users u
                                                          join dbo.UserRole ur on ur.UserId = u.UserId
                                                          join dbo.Roles r on r.RoleId = ur.RoleId
                                                          where u.PeopleId = @pid)
order by ISNULL(ot.Description, 'ZZ'), org.OrganizationName

Python Script

Below is the Python script for the My Involvement widget. As supplied by TouchPoint, the file name is WidgetInvolvementPython.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def Get():
    sql = Data.SQLContent
    template = Data.HTMLContent
    orgleadersonly = False

    for item in Data.CurrentUser.UserRoles:
        if item.Role.RoleName == 'OrgLeadersOnly':
            orgleadersonly = True

    params = {'olo': orgleadersonly, 'pid': Data.CurrentPerson.PeopleId}
    results = q.QuerySql(sql, params)
    currentOrgType = "Other"
    for item in results:
        if item.Description != currentOrgType:
            item.New = 'New'
            currentOrgType = item.Description

    Data.results = results
    print model.RenderTemplate(template)


Get()


Latest Update

04/30/2020

Added this article.