Пример #1
0
def request_certificate(mode):
    """ The request call comes from the Search Bar or from the Identity page
    #@app.route('/user/request_certificate/', methods=['GET', 'POST'])
    """
    check_login()
    if request.method == 'GET':
        session['credential_issuer_username'] = request.args.get(
            'issuer_username')
        # check if campaign exist
        campaign = company.Campaign(session['credential_issuer_username'],
                                    mode)
        if not campaign.get_list():
            flash('This company as no active campaign', 'warning')
            return redirect(mode.server + 'user/')
        return render_template('./issuer/request_certificate.html',
                               **session['menu'])

    if request.method == 'POST':
        select = ""
        reviewer = company.Employee(session['credential_issuer_username'],
                                    mode)
        reviewer_list = reviewer.get_list('reviewer', 'all')
        for reviewer in reviewer_list:
            session['select'] = select + """<option value=""" + reviewer[
                'username'].split('.')[0] + """>""" + reviewer[
                    'username'].split('.')[0] + """</option>"""

        if request.form['certificate_type'] == 'experience':
            return render_template(
                './issuer/request_experience_credential.html',
                **session['menu'],
                select=session['select'])

        elif request.form['certificate_type'] == 'reference':
            return render_template(
                './issuer/request_reference_credential.html',
                **session['menu'],
                select=session['select'])

        else:
            flash('credential not available', 'warning')
            return redirect(mode.server + 'user/')
Пример #2
0
def company_dashboard(mode):
    """
    # @route /company/dashboard/
    """
    # created, user_name, reviewer_name, issuer_name, status, credential, id
    issuer_select = ""
    employee = company.Employee(session['host'], mode)
    issuer_list = employee.get_list('issuer', 'all')
    for issuer in issuer_list:
        issuer_select += """<option value=""" + issuer['username'].split('.')[
            0] + """>""" + issuer['username'].split('.')[0] + """</option>"""

    reviewer_select = ""
    reviewer_list = employee.get_list('reviewer', 'all')
    for reviewer in reviewer_list:
        reviewer_select += """<option value=""" + reviewer['username'].split(
            '.')[0] + """>""" + reviewer['username'].split(
                '.')[0] + """</option>"""

    if request.method == 'GET':

        # init of dashboard display / role
        if session['role'] == 'reviewer':
            issuer_query = 'all'
            reviewer_query = session['employee']
        elif session['role'] == 'issuer':
            issuer_query = session['employee']
            reviewer_query = 'all'
        else:
            issuer_query = 'all'
            reviewer_query = 'all'

        # init of dashboard display / credential status
        signed = drafted = reviewed = ""
        if session['role'] == 'issuer':
            reviewed = "checked"
            status = ("reviewed", "", "")
        elif session['role'] == 'reviewer':
            drafted = 'checked'
            status = ('drafted', "", "")
        else:
            drafted = reviewed = signed = "checked"
            status = ('drafted', 'reviewed', 'signed')

        # display dashboard
        credential_list = credential_list_html(session['host'], issuer_query,
                                               reviewer_query, status, mode)
        return render_template('./issuer/company_dashboard.html',
                               **session['menu'],
                               credential_list=credential_list,
                               drafted=drafted,
                               reviewed=reviewed,
                               signed=signed,
                               reviewer_select=reviewer_select,
                               manager_select=issuer_select)

    if request.method == 'POST':

        # update dashboard with select
        status = (request.form.get('draftedbox',
                                   ""), request.form.get('reviewedbox', ""),
                  request.form.get('signedbox', ""))
        drafted = "checked" if request.form.get('draftedbox') else ""
        signed = "checked" if request.form.get('signedbox') else ""
        reviewed = "checked" if request.form.get('reviewedbox') else ""

        if session['role'] == 'reviewer':
            issuer_query = 'all'
            reviewer_query = session['employee']
        else:
            issuer_query = request.form['issuer']
            reviewer_query = request.form['reviewer']
        credential_list = credential_list_html(session['host'], issuer_query,
                                               reviewer_query, status, mode)
        return render_template('./issuer/company_dashboard.html',
                               **session['menu'],
                               credential_list=credential_list,
                               drafted=drafted,
                               reviewed=reviewed,
                               signed=signed,
                               reviewer_select=reviewer_select,
                               manager_select=issuer_select)
Пример #3
0
def issuer_explore(mode):
    check_login()
    issuer_username = request.args['issuer_username']
    if 'issuer_username' not in session or session[
            'issuer_username'] != issuer_username:
        if not ns.username_exist(issuer_username, mode):
            flash('Issuer data not available', 'danger')
            return redirect(mode.server + 'user/')
        issuer_workspace_contract = ns.get_data_from_username(
            issuer_username, mode)['workspace_contract']
        logging.info(' , issuer = %s', issuer_workspace_contract)
        session['issuer_explore'] = Identity(
            issuer_workspace_contract,
            mode,
            authenticated=True,
        ).__dict__.copy()
        session['issuer_username'] = issuer_username
        session['issuer_explore']['method'] = ns.get_method(
            session['issuer_explore']['workspace_contract'], mode)
        if not session['issuer_explore']['method']:
            session['issuer_explore']['method'] = 'ethr'

    #issuer_picture = session['issuer_explore']['picture']
    if session['issuer_explore']['type'] == 'person':
        # file
        if session['issuer_explore']['identity_file'] == []:
            my_file = """<p class="text-center text-muted m-0 " style="font-size: 20px;">No data available</p>"""
        else:
            my_file = ""
            #is_encrypted = False
            for one_file in session['issuer_explore']['identity_file']:
                if one_file.get('content') == 'Encrypted':
                    #is_encrypted = True
                    file_html = """
					<b>File Name</b> : """ + one_file[
                        'filename'] + """ ( """ + 'Not available - Encrypted ' + """ ) <br>
					<b>Created</b> : """ + one_file['created'] + """<br>"""
                else:
                    file_html = """
					<b>File Name</b> : """ + one_file['filename'] + """ ( """ + one_file[
                        'privacy'] + """ ) <br>
					<b>Created</b> : """ + one_file['created'] + """<br>
					<a class="text-secondary" href=/user/download/?filename=""" + one_file[
                            'filename'] + """>
						<i data-toggle="tooltip" class="fa fa-download" title="Download"></i>
					</a>"""
                my_file = my_file + file_html + """<br>"""

        # experience
        experiences = []
        for experience in session['issuer_explore']['certificate']:
            if experience['credentialSubject'][
                    'credentialCategory'] == 'experience':
                experiences.append(experience)
        for experience in session['issuer_explore']['experience']:
            experiences.append(experience)
        # tri par date
        for i, experience in enumerate(experiences):
            min = i
            try:
                DTmin = time.strptime(experience['end_date'], "%Y-%m-%d")
            except:
                DTmin = time.strptime(
                    experience['credentialSubject']['endDate'], "%Y-%m-%d")
            for j, certi in enumerate(experiences[i::]):
                try:
                    DTcerti = time.strptime(certi['end_date'], "%Y-%m-%d")
                except:
                    DTcerti = time.strptime(
                        certi['credentialSubject']['endDate'], "%Y-%m-%d")
                if DTcerti < DTmin:
                    min = j + i
                    DTmin = DTcerti
            experiences[i], experiences[min] = experiences[min], experiences[i]
        experiences = experiences[::-1]

        carousel_indicators_experience = """<li data-target="#experience-carousel" data-slide-to="0" class="active" style="margin-bottom: 0;"></li>"""
        carousel_rows_experience = ""
        if experiences == []:
            pass
        else:
            nbr_rows = (len(experiences) - 1) // 3
            for i in range(nbr_rows):
                carousel_indicators_experience += '<li data-target="#experience-carousel" data-slide-to="{}"></li>'.format(
                    i + 1)
            for i, experience in enumerate(experiences):
                # for verifiable credentials
                try:
                    logo = experience['credentialSubject']['companyLogo']
                    startDate = experience['credentialSubject']['startDate']
                    endDate = experience['credentialSubject']['endDate']
                    description = experience['credentialSubject'][
                        'description']
                    title = experience['credentialSubject']['title']
                    issuer_name = experience['credentialSubject'][
                        'companyName']

                # for self claims
                except:
                    logo = 'QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT'
                    startDate = experience['start_date']
                    endDate = experience['end_date']
                    description = experience['description']
                    title = experience['title']
                    issuer_name = ""

                if logo != None:
                    if not path.exists(mode.uploads_path + logo):
                        url = 'https://gateway.pinata.cloud/ipfs/' + logo
                        response = requests.get(url, stream=True)
                        with open(mode.uploads_path + logo, 'wb') as out_file:
                            shutil.copyfileobj(response.raw, out_file)
                            del response

                if i % 3 == 0:
                    carousel_rows_experience += '<div class="carousel-item px-2 {a}"><div class="row" style="flex-direction: row;">'.format(
                        a="active" if (i == 0) else '')
                carousel_rows_experience += """<div class="col-md-4 mb-2" ><figure class="snip1253 mw-100" style="height: 410px; "><div class="image text-center h-100" style="background-color: white;" ><img src="""
                #image
                try:
                    carousel_rows_experience += """"{}" style="height: 200px;" alt="Loading error"/></div><figcaption class="p-0">""".format(
                        "/uploads/" + logo)
                except:
                    carousel_rows_experience += """"https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample59.jpg" alt="Loading error"/></div><figcaption >"""
                #verified
                if experience.get('topic') != 'certificate':
                    carousel_rows_experience += """<div class="row overflow-hidden" style="flex-direction: row;height: 50px"><div class="col bg-transparent px-2" style="max-width:60px;" ><i class="fa fa-pencil-square-o" style="color: #747474;font-size: 50px;"></i></div>"""
                else:
                    carousel_rows_experience += """<div class="row overflow-hidden" style="flex-direction: row;height: 50px"><div class="col bg-transparent px-2" style="max-width:60px;" ><i class="material-icons my-auto" style="color: rgb(60,158,255);font-size: 50px;">verified_user</i></div>"""
                #header
                carousel_rows_experience += "<div class='col px-0 my-auto'><h4 class='align-center' style='color: black;font-size: 1.4em'>" + title + "</h4></div></div><hr class='my-1'>"
                #body
                if experience.get('topic') == 'certificate':
                    carousel_rows_experience += """<p  style="font-size: 1em"><b>Issuer name : </b>""" + issuer_name + """<br>"""

                carousel_rows_experience += """<b>Start Date</b> : """ + startDate + """<br> """
                carousel_rows_experience += """<b>End Date</b> : """ + endDate + """<br>"""
                if experience.get('topic') != 'experience':
                    carousel_rows_experience += """<b>Description</b> : """ + description[:
                                                                                          100:]
                    if len(description) > 100:
                        carousel_rows_experience += "...<br>"
                    else:
                        carousel_rows_experience += "<br>"
                else:
                    carousel_rows_experience += """<b>Description</b> : """ + description[:
                                                                                          150:]
                    if len(description) > 150:
                        carousel_rows_experience += "...<br>"
                    else:
                        carousel_rows_experience += "<br>"
                carousel_rows_experience += "</p>"
                #Footer
                if experience.get('topic') != 'certificate':
                    carousel_rows_experience += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #c9c9c9; text-align:center;font-size: 1em; color:black;">Self claim</footer>"""
                    #carousel_rows_experience += """<a href= /certificate/?certificate_id=""" + experience['id'] + """:experience> </a>"""
                else:
                    carousel_rows_experience += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #3c9eff; text-align:center;font-size: 1em;" >Certified by """ + issuer_name + """</footer>"""
                    carousel_rows_experience += """<a href=  """ + mode.server + """certificate/?certificate_id=did:talao:""" + mode.BLOCKCHAIN + """:""" + session[
                        'issuer_explore']['workspace_contract'][
                            2:] + """:document:""" + str(
                                experience['doc_id']) + """></a>"""

                carousel_rows_experience += """</figure></div>"""
                if (i + 1) % 3 == 0 and (len(experiences) % 3 != 0
                                         or len(experiences) != i + 1):
                    carousel_rows_experience += '</div></div>'
                if i == len(experiences) - 1:
                    carousel_rows_experience += '</div></div>'

        # recommendation
        recommendations = []
        for certificate in session['issuer_explore']['certificate']:
            if certificate['type'] == "recommendation":
                recommendations.append(certificate)

        carousel_indicators_recommendation = """<li data-target="#recommendation-carousel" data-slide-to="0" class="active" style="margin-bottom: 0;"></li>"""
        carousel_rows_recommendation = ""
        if recommendations == []:
            pass
        else:
            nbr_rows = (len(recommendations) - 1) // 3
            for i in range(nbr_rows):
                carousel_indicators_recommendation += '<li data-target="#recommendation-carousel" data-slide-to="{}"></li>'.format(
                    i + 1)
            for i, recommendation in enumerate(recommendations):

                if recommendation['issuer']['type'] == 1001:
                    issuer_name = recommendation['issuer'][
                        'firstname'] + ' ' + recommendation['issuer'][
                            'lastname']
                else:
                    issuer_name = recommendation['issuer']['name']

                try:
                    logo = recommendation['logo']
                except:
                    try:
                        logo = recommendation['picture']
                    except:
                        logo = 'QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT'

                if logo:
                    if not path.exists(mode.uploads_path + logo):
                        url = 'https://gateway.pinata.cloud/ipfs/' + logo
                        response = requests.get(url, stream=True)
                        with open(mode.uploads_path + logo, 'wb') as out_file:
                            shutil.copyfileobj(response.raw, out_file)
                            del response

                if i % 3 == 0:
                    carousel_rows_recommendation += '<div class="carousel-item {a}"><div class="row">'.format(
                        a="active" if (i == 0) else '')
                carousel_rows_recommendation += """<div class="col-md-4 mb-2" ><figure class="snip1253 mw-100" style="height: 410px; "><div class="image text-center h-100" style="background-color: white;" ><img src="""
                #image
                try:
                    carousel_rows_recommendation += """"{}" style="height: 200px;" alt="Loading error"/></div><figcaption class="p-0">""".format(
                        "/uploads/" + logo)
                except:
                    carousel_rows_recommendation += """"https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample59.jpg" alt="Loading error"/></div><figcaption >"""
                #verified
                carousel_rows_recommendation += """<div class="row overflow-hidden" style="flex-direction: row;height: 50px"><div class="col bg-transparent px-2" style="max-width:60px;" ><i class="material-icons my-auto" style="color: rgb(60,158,255);font-size: 50px;">verified_user</i></div>"""
                #header
                carousel_rows_recommendation += "<div class='col px-0 my-auto'><h4 class='align-center' style='color: black;font-size: 1.4em'>" + recommendation.get(
                    'title', "") + "</h4></div></div>"
                #body
                carousel_rows_recommendation += """<hr class="my-1"><p style="font-size: 1em"><b>Referent name: </b>""" + issuer_name + "<br>"
                carousel_rows_recommendation += """<b> Relationship: </b>""" + recommendation[
                    'relationship'] + "<br>"
                carousel_rows_recommendation += """<b> Description: </b>""" + recommendation[
                    'description'][:100]
                if len(recommendation['description']) > 100:
                    carousel_rows_recommendation += "...<br>"
                else:
                    carousel_rows_recommendation += "<br>"

                carousel_rows_recommendation += "</p>"
                #Footer
                carousel_rows_recommendation += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #3c9eff; text-align:center;font-size: 1em; color:white;">Certified by """ + issuer_name + """</footer>"""
                #Lien certificates
                carousel_rows_recommendation += """<a href=  """ + mode.server + """certificate/?certificate_id=did:talao:""" + mode.BLOCKCHAIN + """:""" + session[
                    'issuer_explore']['workspace_contract'][
                        2:] + """:document:""" + str(
                            recommendation['doc_id']) + """></a>"""

                carousel_rows_recommendation += """</figure></div>"""
                if (i + 1) % 3 == 0 and (len(recommendations) % 3 != 0
                                         or len(recommendations) != i + 1):
                    carousel_rows_recommendation += '</div></div>'
                if i == len(recommendations) - 1:
                    carousel_rows_recommendation += '</div></div>'

        # Education
        carousel_indicators_education = """<li data-target="#education-carousel" data-slide-to="0" class="active" style="margin-bottom: 0;"></li>"""
        carousel_rows_education = ""
        if session['issuer_explore']['education'] == []:
            pass
        else:
            educations = session['issuer_explore']['education']
            nbr_rows = (len(educations) - 1) // 3
            for i in range(nbr_rows):
                carousel_indicators_education += '<li data-target="#education-carousel" data-slide-to="{}"></li>'.format(
                    i + 1)
            for i, education in enumerate(
                    session['issuer_explore']['education']):
                try:
                    logo = education['logo']
                except:
                    try:
                        logo = education['picture']
                    except:
                        logo = 'QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT'

                if logo != None:
                    if not path.exists(mode.uploads_path + logo):
                        url = 'https://gateway.pinata.cloud/ipfs/' + logo
                        response = requests.get(url, stream=True)
                        with open(mode.uploads_path + logo, 'wb') as out_file:
                            shutil.copyfileobj(response.raw, out_file)
                            del response

                if i % 3 == 0:
                    carousel_rows_education += '<div class="carousel-item {a}"><div class="row">'.format(
                        a="active" if (i == 0) else '')
                carousel_rows_education += """<div class="col-md-4 mb-2" ><figure class="snip1253 mw-100" style="height: 410px; "><div class="image text-center h-100" style="background-color: white;" ><img src="""
                #image
                try:
                    carousel_rows_education += """"{}" style="height: 200px;" alt="Loading error"/></div><figcaption class="p-0">""".format(
                        "/uploads/" + logo)
                except:
                    carousel_rows_education += """"https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample59.jpg" alt="Loading error"/></div><figcaption >"""
                #verified
                carousel_rows_education += """<div class="row overflow-hidden" style="flex-direction: row;height: 50px"><div class="col bg-transparent px-2" style="max-width:60px;" ><i class="fa fa-pencil-square-o" style="color: #747474;font-size: 50px;"></i></div>"""
                #header
                carousel_rows_education += "<div class='col px-0 my-auto'><h4 class='align-center' style='color: black;font-size: 1.4em'>" + education[
                    'title'] + "</h4></div></div>"
                #body
                carousel_rows_education += """<hr class="my-1"><p style="font-size: 1em"><b>Name: </b>""" + education[
                    'organization']['name'] + '<br>'

                carousel_rows_education += """<b>Start Date</b> : """ + education[
                    'start_date'] + """<br> """
                carousel_rows_education += """<b>End Date</b> : """ + education[
                    'end_date'] + """<br>"""

                carousel_rows_education += "</p>"
                #Footer
                carousel_rows_education += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #c9c9c9; text-align:center;font-size: 1em; color:black;">Self claim</footer>"""
                #Lien certificates
                #carousel_rows_education += """<a href=  /certificate/?certificate_id="""+education['id'] + """:education></a>"""

                carousel_rows_education += """</figure></div>"""
                if (i + 1) % 3 == 0 and (len(educations) % 3 != 0
                                         or len(educations) != i + 1):
                    carousel_rows_education += '</div></div>'
                if i == len(educations) - 1:
                    carousel_rows_education += '</div></div>'

        # Skills
        skills = []
        for certificate in session['issuer_explore']['certificate']:
            if certificate['type'] == "skill":
                skills.append(certificate)

        carousel_indicators_skill = """<li data-target="#skill-carousel" data-slide-to="0" class="active" style="margin-bottom: 0;"></li>"""
        carousel_rows_skill = ""
        if skills == []:
            if session['issuer_explore']['skills'] == None:
                pass
            else:
                if session['issuer_explore']['skills']['description'] != None:
                    carousel_rows_skill += '<div class="carousel-item active"><div class="row">'
                    carousel_rows_skill += """<div class="col-md-4 mb-2">
							<figure class="snip1253 mw-100" style="height: 410px; ">
							  <div class="image text-center h-100" style="background-color: white;"><img src="/uploads/QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT" style="height: 200px;" alt="Loading error" /></div>
							  <figcaption class="p-0">
								<div class="row overflow-hidden" style="flex-direction: row;height: 50px">
								  <div class="col bg-transparent px-2" style="max-width:60px;"><i class="fa fa-pencil-square-o" style="color: #747474;font-size: 50px;"></i></div>
								  <div class='col px-0 my-auto'>
									<h4 class='align-center' style='color: black;font-size: 1.4em'>Self claimed skills</h4>
								  </div>
								</div>
								<hr class="my-1">
								<p class="text-center" style="font-size: 1em;">"""
                    for i, skill in enumerate(session['issuer_explore']
                                              ['skills']['description']):
                        if i < 4:
                            carousel_rows_skill += skill['skill_name'] + "<br>"
                        elif i == 4:
                            carousel_rows_skill += ""
                    carousel_rows_skill += """</p></figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #c9c9c9; text-align:center;font-size: 1em; color:black;">Self claim</footer>"""
                    #carousel_rows_skill += """<a href=  /certificate/?certificate_id="""+ session['issuer_explore']['skills']['id'] + """:skills></a>"""
                    carousel_rows_skill += """</figure></div>"""
                    carousel_rows_skill += '</div></div>'
        else:
            nbr_rows = (len(skills) - 1) // 3
            for i in range(nbr_rows):
                carousel_indicators_skill += '<li data-target="#skill-carousel" data-slide-to="{}"></li>'.format(
                    i + 1)
            for i, skill in enumerate(skills):
                try:
                    logo = skill['logo']
                except:
                    logo = 'QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT'

                if logo != None:
                    if not path.exists(mode.uploads_path + logo):
                        url = 'https://gateway.pinata.cloud/ipfs/' + logo
                        response = requests.get(url, stream=True)
                        with open(mode.uploads_path + logo, 'wb') as out_file:
                            shutil.copyfileobj(response.raw, out_file)
                            del response

                if i % 3 == 0:
                    carousel_rows_skill += '<div class="carousel-item {a}"><div class="row">'.format(
                        a="active" if (i == 0) else '')
                carousel_rows_skill += """<div class="col-md-4 mb-2" ><figure class="snip1253 mw-100" style="height: 410px; "><div class="image text-center h-100" style="background-color: white;" ><img src="""
                #image
                try:
                    carousel_rows_skill += """"{}" style="height: 200px;" alt="Loading error"/></div><figcaption class="p-0">""".format(
                        "/uploads/" + logo)
                except:
                    carousel_rows_skill += """"https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample59.jpg" alt="Loading error"/></div><figcaption >"""
                #verified
                carousel_rows_skill += """<div class="row overflow-hidden" style="flex-direction: row;height: 50px"><div class="col bg-transparent px-2" style="max-width:60px;" ><i class="material-icons my-auto" style="color: rgb(60,158,255);font-size: 50px;">verified_user</i></div>"""
                #header
                carousel_rows_skill += "<div class='col px-0 my-auto'><h4 class='align-center' style='color: black;font-size: 1.4em'>" + skill[
                    'title'] + "</h4></div></div>"
                #body
                carousel_rows_skill += """<hr class="my-1"><p class="text-center" style="font-size: 1em;">"""

                lines = skill['description'].split("\n")
                for l in lines:
                    carousel_rows_skill += l.strip("\r") + "<br>"

                carousel_rows_skill += "</p>"
                #Footer
                if skill['issuer']['type'] == 'company':
                    carousel_rows_skill += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #3c9eff; text-align:center;font-size: 1em;" >Certified by """ + skill[
                        'issuer']['name'] + """</footer>"""
                else:
                    carousel_rows_skill += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #3c9eff; text-align:center;font-size: 1em;" >Certified by """ + skill[
                        'issuer']['firstname'] + " " + skill['issuer'][
                            'lastname'] + """</footer>"""
                #Lien certificates
                #carousel_rows_skill += """<a href=  """+ mode.server + """certificate/?certificate_id=did:talao:""" + mode.BLOCKCHAIN + """:""" + session['issuer_explore']['workspace_contract'][2:] + """:document:""" + str(skill['doc_id']) + """></a>"""

                carousel_rows_skill += """</figure></div>"""
                if (i + 1) % 3 == 0 and (len(skills) % 3 != 0
                                         or len(skills) != i + 1):
                    carousel_rows_skill += '</div></div>'
                if i == len(skills) - 1:
                    created_row = False
                    if (i + 1) % 3 == 0:
                        carousel_rows_skill += '<div class="carousel-item"><div class="row">'
                        created_row = True
                    carousel_rows_skill += """<div class="col-md-4 mb-2">
							<figure class="snip1253 mw-100" style="height: 410px; ">
							  <div class="image text-center h-100" style="background-color: white;"><img src="/uploads/QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT" style="height: 200px;" alt="Loading error" /></div>
							  <figcaption class="p-0">
								<div class="row overflow-hidden" style="flex-direction: row;height: 50px">
								  <div class="col bg-transparent px-2" style="max-width:60px;"><i class="fa fa-pencil-square-o" style="color: #747474;font-size: 50px;"></i></div>
								  <div class='col px-0 my-auto'>
									<h4 class='align-center' style='color: black;font-size: 1.4em'>Self claimed skills</h4>
								  </div>
								</div>
								<hr class="my-1">
								<p class="text-center" style="font-size: 1em;">"""
                    for i, skill in enumerate(session['issuer_explore']
                                              ['skills']['description']):
                        if i < 4:
                            carousel_rows_skill += skill['skill_name'] + "<br>"
                        elif i == 4:
                            carousel_rows_skill += "..."
                    carousel_rows_skill += """</p></figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #c9c9c9; text-align:center;font-size: 1em; color:black;">Self claim</footer>"""
                    carousel_rows_skill += """<a href=  /data/?dataId=""" + session[
                        'issuer_explore']['skills']['id'] + """:skills></a>"""
                    carousel_rows_skill += """</figure></div>"""

                    if created_row:
                        carousel_rows_skill += '</div></div>'
                    carousel_rows_skill += '</div></div>'
        #Services
        if session['type'] == 'person':
            referent_list = is_username_in_list(session['issuer'],
                                                issuer_username)
            # est ce qu il est dans ma partnership list
            partner_list = is_username_in_list_for_partnership(
                session['partner'], issuer_username)
            # est ce que je suis dans l'issuer list de ce Talent ?
            in_referent_list = is_username_in_list(
                session['issuer_explore']['issuer_keys'], session['username'])

        is_manager = False
        if session['type'] == 'company':
            host_name = session['username'] if len(session['username'].split(
                '.')) == 1 else session['username'].split('.')[1]
            referent_list = is_username_in_list(session['issuer'],
                                                issuer_username)
            is_manager = company.Employee(host_name,
                                          mode).exist(issuer_username)
            in_referent_list = is_username_in_list(
                session['issuer_explore']['issuer_keys'], host_name)
            partner_list = not is_username_in_list_for_partnership(
                session['partner'], issuer_username)

        # personal details
        adress = session['issuer_explore']['personal']['postal_address'][
            'claim_value']
        phone = session['issuer_explore']['personal']['contact_phone'][
            'claim_value']
        email = session['issuer_explore']['personal']['contact_email'][
            'claim_value']
        birth_date = session['issuer_explore']['personal']['birthdate'][
            'claim_value']
        education = session['issuer_explore']['personal']['education'][
            'claim_value']
        about = session['issuer_explore']['personal']['about']['claim_value']
        return render_template(
            './person_issuer_identity.html',
            **session['menu'],
            issuer_name=session['issuer_explore']['name'],
            issuer_address=session['issuer_explore']['address'],
            issuer_username=issuer_username,
            issuer_profil_title=session['issuer_explore']['profil_title'],
            issuer_picturefile=session['issuer_explore']['picture'],
            digitalvault=my_file,
            adress=adress,
            phone=phone,
            email=email,
            birth_date=birth_date,
            education=education,
            about=about,
            user_type=session['type'],
            referent_list=referent_list,
            partner_list=partner_list,
            in_referent_list=in_referent_list,
            is_manager=is_manager,
            carousel_indicators_experience=carousel_indicators_experience,
            carousel_indicators_recommendation=
            carousel_indicators_recommendation,
            carousel_indicators_education=carousel_indicators_education,
            carousel_indicators_skill=carousel_indicators_skill,
            carousel_rows_experience=carousel_rows_experience,
            carousel_rows_recommendation=carousel_rows_recommendation,
            carousel_rows_education=carousel_rows_education,
            carousel_rows_skill=carousel_rows_skill)

    if session['issuer_explore']['type'] == 'company':

        # file
        if session['issuer_explore']['identity_file'] == []:
            my_file = """<a class="text-info">No Files available</a>"""
        else:
            my_file = ""
            for one_file in session['issuer_explore']['identity_file']:
                if one_file.get('content') == 'Encrypted':
                    file_html = """
					<b>File Name</b> : """ + one_file[
                        'filename'] + """ ( """ + 'Not available - Encrypted ' + """ ) <br>
					<b>Created</b> : """ + one_file['created'] + """<br>"""
                else:
                    file_html = """
					<b>File Name</b> : """ + one_file['filename'] + """ ( """ + one_file[
                        'privacy'] + """ ) <br>
					<b>Created</b> : """ + one_file['created'] + """<br>
					<a class="text-secondary" href=/user/download/?filename=""" + one_file[
                            'filename'] + """>
						<i data-toggle="tooltip" class="fa fa-download" title="Download"></i>
					</a>"""
                my_file = my_file + file_html + """<br>"""

        #aggrement credentials
        agreements = []
        for certificate in session['issuer_explore']['certificate']:
            try:
                if certificate['credentialSubject'][
                        'credentialCategory'] == 'agreement':
                    agreements.append(certificate)
            except:
                pass
        carousel_indicators_agreement = """<li data-target="#agreement-carousel" data-slide-to="0" class="active" style="margin-bottom: 0;"></li>"""
        carousel_rows_agreement = ""
        if agreements == []:
            pass
        else:
            nbr_rows = (len(agreements) - 1) // 3
            for i in range(nbr_rows):
                carousel_indicators_agreement += '<li data-target="#agreement-carousel" data-slide-to="{}"></li>'.format(
                    i + 1)
            for i, agreement in enumerate(agreements):
                try:
                    logo = agreement['issued_by']['logo']
                except:
                    logo = 'QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT'

                if logo != None:
                    if not path.exists(mode.uploads_path + logo):
                        url = 'https://gateway.pinata.cloud/ipfs/' + logo
                        response = requests.get(url, stream=True)
                        with open(mode.uploads_path + logo, 'wb') as out_file:
                            shutil.copyfileobj(response.raw, out_file)
                            del response

                if i % 3 == 0:
                    carousel_rows_agreement += '<div class="carousel-item {a}"><div class="row">'.format(
                        a="active" if (i == 0) else '')
                carousel_rows_agreement += """<div class="col-md-4 mb-2" ><figure class="snip1253 mw-100" style="height: 410px; "><div class="image p-2 text-center h-100" style="background-color: white;" ><img src="""
                #image
                try:
                    carousel_rows_agreement += """"{}" style="height: 180px;" alt="Loading error"/></div><figcaption class="p-0">""".format(
                        "/uploads/" + logo)
                except:
                    carousel_rows_agreement += """"https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample59.jpg" alt="Loading error"/></div><figcaption >"""
                #verified
                carousel_rows_agreement += """<div class="row overflow-hidden" style="flex-direction: row;height: 50px"><div class="col bg-transparent px-2" style="max-width:60px;" ><i class="material-icons my-auto" style="color: rgb(60,158,255);font-size: 50px;">verified_user</i></div>"""
                #header
                carousel_rows_agreement += "<div class='col px-0 my-auto'><h4 class='align-center' style='color: black;font-size: 1.4em'>" + agreement[
                    'title'] + "</h4></div></div>"
                #body
                carousel_rows_agreement += """<hr class="my-1"><p class="my-0" style="font-size: 1em"><b>Issuer Name: </b>""" + agreement[
                    'issuer']['name'] + '<br>'

                carousel_rows_agreement += """<b>Issue date</b> : """ + agreement[
                    'date_of_issue'] + """<br> """
                carousel_rows_agreement += """<b>End of validity date</b> : """ + agreement[
                    'valid_until'] + """<br>"""

                carousel_rows_agreement += """<b> Description: </b>""" + agreement[
                    'description'][:150]
                if len(agreement['description']) > 150:
                    carousel_rows_agreement += "...<br>"
                else:
                    carousel_rows_agreement += "<br>"
                carousel_rows_agreement += "</p>"
                #Footer
                carousel_rows_agreement += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #3c9eff; text-align:center;font-size: 1em;" >Certified by """ + agreement[
                    'issuer']['name'] + """</footer>"""
                #Lien certificates
                carousel_rows_agreement += """<a href=  /certificate/?certificate_id=""" + agreement[
                    'id'] + """></a>"""

                carousel_rows_agreement += """</figure></div>"""
                if (i + 1) % 3 == 0 and len(agreements) % 3 != 0:
                    carousel_rows_agreement += '</div></div>'
                if i == len(agreements) - 1:
                    carousel_rows_agreement += '</div></div>'

        # reference credentials
        references = []
        for certificate in session['issuer_explore']['certificate']:
            try:
                if certificate['credentialSubject'][
                        'credentialCategory'] == 'reference':
                    references.append(certificate)
            except:
                pass
        carousel_indicators_reference = """<li data-target="#reference-carousel" data-slide-to="0" class="active" style="margin-bottom: 0;"></li>"""
        carousel_rows_reference = ""
        if not references:
            pass
        else:
            nbr_rows = (len(references) - 1) // 3
            for i in range(nbr_rows):
                carousel_indicators_reference += '<li data-target="#reference-carousel" data-slide-to="{}"></li>'.format(
                    i + 1)
            for i, reference in enumerate(references):

                logo = reference['credentialSubject']['companyLogo']
                startDate = reference['credentialSubject']['offers'][
                    'startDate']
                endDate = reference['credentialSubject']['offers']['endDate']
                description = reference['credentialSubject']['offers'][
                    'description']
                title = reference['credentialSubject']['offers']['title']
                issuer_name = reference['credentialSubject']['companyName']
                budget = reference['credentialSubject']['offers']['price']

                if not logo:
                    logo = 'QmSbxr8xkucse2C1aGMeQ5Wt12VmXL96AUUpiBuMhCrrAT'

                if not path.exists(mode.uploads_path + logo):
                    url = 'https://gateway.pinata.cloud/ipfs/' + logo
                    response = requests.get(url, stream=True)
                    with open(mode.uploads_path + logo, 'wb') as out_file:
                        shutil.copyfileobj(response.raw, out_file)
                        del response

                if i % 3 == 0:
                    carousel_rows_reference += '<div class="carousel-item {a}"><div class="row">'.format(
                        a="active" if (i == 0) else '')
                carousel_rows_reference += """<div class="col-md-4 mb-2" ><figure class="snip1253 mw-100" style="height: 410px; "><div class="image text-center h-100" style="background-color: white;" ><img src="""
                #image
                try:
                    carousel_rows_reference += """"{}" style="height: 200px;" alt="Loading error"/></div><figcaption class="p-0">""".format(
                        "/uploads/" + logo)
                except:
                    carousel_rows_reference += """"https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sample59.jpg" alt="Loading error"/></div><figcaption >"""
                #verified
                carousel_rows_reference += """<div class="row overflow-hidden" style="flex-direction: row;height: 50px"><div class="col bg-transparent px-2" style="max-width:60px;" ><i class="material-icons my-auto" style="color: rgb(60,158,255);font-size: 50px;">verified_user</i></div>"""
                #header
                carousel_rows_reference += "<div class='col px-0 my-auto'><h4 class='align-center' style='color: black;font-size: 1.4em'>" + title + "</h4></div></div>"
                #body
                carousel_rows_reference += """<hr class="my-1"><p class="my-0" style="font-size: 1em"><b>Issuer Name: </b>""" + issuer_name + '<br>'

                carousel_rows_reference += """<b>Start date</b> : """ + startDate + """<b>	End date</b> : """ + endDate + """<br> """
                carousel_rows_reference += """<b>Project Budget</b> : """ + budget + """<br> """

                carousel_rows_reference += """<b> Description: </b>""" + description[:
                                                                                     150]
                if len(description) > 150:
                    carousel_rows_reference += "...<br>"
                else:
                    carousel_rows_reference += "<br>"
                carousel_rows_reference += "</p>"
                #Footer
                carousel_rows_reference += """</figcaption><footer class="w-100" style="position: absolute; bottom:0; background-color: #3c9eff; text-align:center;font-size: 1em;" >Certified by """ + issuer_name + """</footer>"""
                #Lien certificates
                carousel_rows_reference += """<a href=  /certificate/?certificate_id=""" + reference[
                    'id'] + """></a>"""

                carousel_rows_reference += """</figure></div>"""
                if (i + 1) % 3 == 0 and len(references) % 3 != 0:
                    carousel_rows_reference += '</div></div>'
                if i == len(references) - 1:
                    carousel_rows_reference += '</div></div>'
        #Services
        referent_list = False
        partner_list = False
        in_referent_list = False
        if session['type'] == 'person':
            referent_list = is_username_in_list(session['issuer'],
                                                issuer_username)
            # est ce qu il est dans ma partnership list
            partner_list = is_username_in_list_for_partnership(
                session['partner'], issuer_username)
            # est ce que je suis dans l'issuer list de ce Talent ?
            in_referent_list = is_username_in_list(
                session['issuer_explore']['issuer_keys'], session['username'])

        if session['type'] == 'company':
            host_name = session['username'] if len(session['username'].split(
                '.')) == 1 else session['username'].split('.')[1]
            referent_list = is_username_in_list(session['issuer'],
                                                issuer_username)
            in_referent_list = is_username_in_list(
                session['issuer_explore']['issuer_keys'], host_name)
            partner_list = is_username_in_list_for_partnership(
                session['partner'], issuer_username)

        #kyc
        user_type = session['type']
        contact_name = session['issuer_explore']['personal']['contact_name'][
            'claim_value']
        contact_email = session['issuer_explore']['personal']['contact_email'][
            'claim_value']
        contact_phone = session['issuer_explore']['personal']['contact_phone'][
            'claim_value']
        website = session['issuer_explore']['personal']['website'][
            'claim_value']
        about = session['issuer_explore']['personal']['about']['claim_value']
        staff = session['issuer_explore']['personal']['staff']['claim_value']
        siren = session['issuer_explore']['personal']['siren']['claim_value']
        try:
            sales = "{:,}".format(
                int(session['issuer_explore']['personal']['sales']
                    ['claim_value'])).replace(',', ' ')
        except:
            sales = session['issuer_explore']['personal']['sales'][
                'claim_value']

        if session['issuer_explore']['skills'] is None or session[
                'issuer_explore']['skills'].get('id') is None:
            my_competencies = """<p class="text-center text-muted m-0 " style="font-size: 20px;">No data available</p>"""
        else:
            my_competencies = ""
            for competencie in session['issuer_explore']['skills'][
                    'description']:
                competencie_html = competencie['skill_name'] + """<br>"""
                my_competencies = my_competencies + competencie_html
            my_competencies = my_competencies + """
				<p>
					<a class="text-secondary" href=/data/?dataId=""" + session[
                'issuer_explore']['skills']['id'] + """:skills>
						<i data-toggle="tooltip" class="fa fa-search-plus" title="Data Check"></i>
					</a>
				</p>"""
        return render_template(
            './company_issuer_identity.html',
            **session['menu'],
            issuer_name=session['issuer_explore']['name'],
            issuer_address=session['issuer_explore']['address'],
            issuer_username=issuer_username,
            user_type=user_type,
            issuer_picturefile=session['issuer_explore']['picture'],
            contact_name=contact_name,
            contact_email=contact_email,
            contact_phone=contact_phone,
            website=website,
            about=about,
            staff=staff,
            sales=sales,
            siren=siren,
            digitalvault=my_file,
            referent_list=referent_list,
            partner_list=partner_list,
            in_referent_list=in_referent_list,
            carousel_indicators_agreement=carousel_indicators_agreement,
            carousel_rows_agreement=carousel_rows_agreement,
            carousel_indicators_reference=carousel_indicators_reference,
            carousel_rows_reference=carousel_rows_reference,
            competencies=my_competencies)
Пример #4
0
def add_employee(mode):
    """
    # add admin or issuer or reviewer in table issuer of host
    #@app.route('/user/add_employee/', methods=['GET', 'POST'])
     add_employee(employee_name, identity_name, role, referent, host_name, email, mode, phone=None, password='******') :
    """
    check_login()

    # init employee db access
    employee = company.Employee(session['host'], mode)

    if request.method == 'GET':
        session['role_to_add'] = request.args.get('role_to_add')

        if session['role_to_add'] == 'issuer':
            return render_template('./issuer/add_issuer.html',
                                   **session['menu'])

        elif session['role_to_add'] == 'reviewer':
            issuer_list = employee.get_list('issuer', 'all')
            issuer_select = ""
            for issuer in issuer_list:
                issuer_select += """<option value=""" + issuer[
                    'username'].split('.')[0] + """>""" + issuer[
                        'username'].split('.')[0] + """</option>"""
            return render_template('./issuer/add_reviewer.html',
                                   **session['menu'],
                                   issuer_select=issuer_select)

        elif session['role_to_add'] == 'admin':
            return render_template('./issuer/add_admin.html',
                                   **session['menu'])

    if request.method == 'POST':

        # check if username is new
        if ns.username_exist(request.form['employee_username'],
                             mode) or employee.exist(
                                 request.form['employee_username']):
            flash('This username is already used, lets try an another one !',
                  'warning')
        else:
            employee_username = request.form['employee_username']
            identity_username = request.form['identity_username']

            # let check  who is the referent
            if session['role_to_add'] == 'reviewer':
                if session['role'] in ['admin', 'creator']:
                    referent = request.form['referent_username']
                else:
                    referent = session['employee']
            else:
                referent = None

            #add_employee(employee_name, identity_name, role, referent, host_name, email, mode, phone=None, password='******') :
            if employee.add(employee_username, identity_username,
                            session['role_to_add'], referent,
                            request.form['employee_email']):
                flash(
                    employee_username.lower() + " has been added as " +
                    session['role_to_add'], 'success')

        # clean up
        del session['role_to_add']
        return redirect(mode.server + 'user/')
Пример #5
0
def user(mode):
    """
	#@app.route('/user/', methods = ['GET'])
	Main view for Identity Repository
	We setup Ientity with workspace or username depending of the login method
	"""
    check_login()
    if not session.get('uploaded', False):
        logging.info('start first instanciation')
        if not session.get('workspace_contract'):
            logging.info('Identity set up from username')
            data_from_username = ns.get_data_from_username(
                session['username'], mode)
            session['workspace_contract'] = data_from_username[
                'workspace_contract']
        else:
            logging.info('Identity set up from workspace contract')
            session['username'] = ns.get_username_from_resolver(
                session['workspace_contract'], mode)
        if mode.test:
            user = Identity(session['workspace_contract'],
                            mode,
                            authenticated=True)
        else:
            try:
                user = Identity(session['workspace_contract'],
                                mode,
                                authenticated=True)
            except:
                logging.error('cannot init Identity')
                flash('session aborted', 'warning')
                return render_template('login.html')
        logging.info('end of first intanciation')

        # init session side by redis
        session['uploaded'] = True
        session['type'] = user.type
        session['address'] = user.address
        session['workspace_contract'] = user.workspace_contract
        session['issuer'] = user.issuer_keys
        session['partner'] = user.partners
        session['did'] = user.did
        session['eth'] = user.eth
        session['token'] = user.token
        session['rsa_key'] = user.rsa_key
        session['rsa_key_value'] = user.rsa_key_value
        session['rsa_filename'] = session['did'] + ".pem"
        session['private_key'] = user.private_key
        session['private_key_value'] = user.private_key_value
        session['relay_activated'] = user.relay_activated
        session['personal'] = user.personal
        session['identity_file'] = user.identity_file
        session['name'] = user.name
        session['secret'] = user.secret
        session['picture'] = user.picture
        session['signature'] = user.signature
        session['skills'] = user.skills
        session['certificate'] = user.certificate
        session['private_certificate'] = user.private_certificate
        session['secret_certificate'] = user.secret_certificate
        session[
            'all_certificate'] = user.certificate + user.private_certificate + user.secret_certificate
        session['has_vault_access'] = user.has_vault_access
        session['method'] = ns.get_method(session['workspace_contract'], mode)
        session['mode_server'] = mode.server
        if not session['method']:
            session['method'] = "ethr"
        phone = ns.get_data_from_username(session.get('username'),
                                          mode).get('phone')
        session['phone'] = phone if phone else ""

        if user.type == 'person':
            session['profil_title'] = user.profil_title
            session['experience'] = user.experience
            session['education'] = user.education
            # no credential workflow
            session['host'] = session['employee'] = None
            session['role'] = session['referent'] = None
            clipboard = mode.server + "resume/?did=" + session['did']

            session['check_identity_key'] = False

        if session['type'] == 'company':
            session['profil_title'] = ""
            # data for credential workflow for admin, issuer or reviewer
            try:
                session['host'] = session['username'].split('.')[1]
                session['employee'] = session['username'].split('.')[0]
                session['role'] = ns.get_data_from_username(
                    session['username'], mode)['role']
                session['referent'] = ns.get_data_from_username(
                    session['username'], mode)['referent']
            # for creator
            except:
                session['host'] = session['username']
                session['employee'] = None
                session['role'] = 'creator'
                session['referent'] = None
            clipboard = mode.server + "board/?did=" + session['did']

        # for nav bar menu display
        session['menu'] = {
            'picturefile': session['picture'],
            'username': session.get('username', ""),
            'name': session['name'],
            #'private_key_value' : user.private_key_value,
            'rsa_filename': session['rsa_filename'],
            'profil_title': session['profil_title'],
            'clipboard': clipboard
        }

        # Dashboard start for employees
        if session['role'] in ['issuer', 'reviewer']:
            return redirect(mode.server + 'company/dashboard/')

        # Homepage start for Talent
        #if user.type == 'person' :
        #	return render_template('homepage.html', **session['menu'])

        # check Identity key Pair for person only client side
        # Keypairs for companies are setpu server side
        if not ns.get_did(session['workspace_contract'],
                          mode) and session['type'] == 'person':
            return redirect(mode.server + 'user/generate_identity/')

    else:
        session['check_identity_key'] = True

    # Partners
    if not session['partner']:
        my_partner = """<a class="text-info">No Partners available</a>"""
    else:
        my_partner = ""
        for partner in session['partner']:
            if partner['authorized'] == 'Pending':
                partner_html = """
				<span><a href="/user/issuer_explore/?issuer_username=""" + partner[
                    'username'] + """">""" + partner['username'] + """</a>  (""" + partner[
                        'authorized'] + """ - """ + partner['status'] + """ )
					<a class="text-secondary" href="/user/reject_partner/?partner_username=""" + partner[
                            'username'] + """&amp;partner_workspace_contract=""" + partner[
                                'workspace_contract'] + """">
						<i data-toggle="tooltip" class="fa fa-thumbs-o-down" title="Reject this Partnership.">&nbsp&nbsp&nbsp</i>
					</a>
					<a class="text-secondary" href="/user/authorize_partner/?partner_username=""" + partner[
                                    'username'] + """&amp;partner_workspace_contract=""" + partner[
                                        'workspace_contract'] + """">
						<i data-toggle="tooltip" class="fa fa-thumbs-o-up" title="Authorize this Parnership."></i>
					</a>
				</spn>"""
            elif partner['authorized'] == 'Removed':
                partner_html = """
				<span><a href="/user/issuer_explore/?issuer_username=""" + partner[
                    'username'] + """">""" + partner[
                        'username'] + """</a>  (""" + partner[
                            'authorized'] + """ - """ + partner[
                                'status'] + """ )
				</spn>"""
            else:
                partner_html = """
				<span><a href="/user/issuer_explore/?issuer_username=""" + partner[
                    'username'] + """">""" + partner[
                        'username'] + """</a>  (""" + partner[
                            'authorized'] + """ - """ + partner['status'] + """ )
					<a class="text-secondary" href="/user/remove_partner/?partner_username=""" + partner[
                                'username'] + """&amp;partner_workspace_contract=""" + partner[
                                    'workspace_contract'] + """">
						<i data-toggle="tooltip" class="fa fa-trash-o" title="Remove this Partnership.">&nbsp&nbsp&nbsp</i>
				</spn>"""
            my_partner = my_partner + partner_html + """<br>"""

    # Issuer for document, they have an ERC725 key 20002
    if not session['issuer']:
        my_issuer = """  <a class="text-info">No Referents available</a>"""
    else:
        my_issuer = ""
        for one_issuer in session['issuer']:
            issuer_username = ns.get_username_from_resolver(
                one_issuer['workspace_contract'], mode)
            issuer_username = '******' if issuer_username is None else issuer_username
            issuer_html = """
				<span>""" + issuer_username + """
					<a class="text-secondary" href="/user/remove_issuer/?issuer_username=""" + issuer_username + """&amp;issuer_address=""" + one_issuer[
                'address'] + """">
						<i data-toggle="tooltip" class="fa fa-trash-o" title="Remove">&nbsp&nbsp&nbsp</i>
					</a>
					<a class="text-secondary" href="/user/issuer_explore/?issuer_username=""" + issuer_username + """">
						<i data-toggle="tooltip" class="fa fa-search-plus" title="Data Check"></i>
					</a>
				</span>"""
            my_issuer = my_issuer + issuer_html + """<br>"""

    # files
    if not session['identity_file']:
        my_file = """<a class="text-info">No Files available</a>"""
    else:
        my_file = ""
        for one_file in session['identity_file']:
            file_html = """
				<b>File Name</b> : """ + one_file['filename'] + """ ( """ + one_file[
                'privacy'] + """ ) <br>
				<b>Created</b> : """ + one_file['created'] + """<br>
				<p>
					<a class="text-secondary" href="/user/remove_file/?file_id=""" + one_file[
                    'id'] + """&filename=""" + one_file['filename'] + """">
						<i data-toggle="tooltip" class="far fa-trash-alt" title="Remove">&nbsp&nbsp&nbsp</i>
					</a>

					<a class="text-secondary" href=/user/download/?filename=""" + one_file[
                        'filename'] + """>
						<i data-toggle="tooltip" class="fa fa-download" title="Download"></i>
					</a>
				</p>"""
            my_file = my_file + file_html

    # skills
    if not session['skills'] or not session['skills'].get('id'):
        my_skills = """<a class="text-info">No data available</a>"""
    else:
        my_skills = ""
        for skill in session['skills']['description']:
            skill_html = skill['skill_name'] + """ (""" + skill[
                'skill_level'] + """)""" + """<br>"""
            my_skills = my_skills + skill_html
        my_skills = my_skills + """
				<p>
				</p>"""

    # specific to person
    if session['type'] == 'person':
        # experience
        my_experience = ""
        if not session['experience']:
            my_experience = my_experience + """<a class="text-info">No Experience available</a>"""
        else:
            for experience in sorted(
                    session['experience'],
                    key=lambda d: time.strptime(d['start_date'], "%Y-%m-%d"),
                    reverse=True):
                if not experience['end_date']:
                    end_date = "Current"
                else:
                    end_date = experience['end_date']
                exp_html = """
				<b>Company</b> : """ + experience['company']['name'] + """<br>
				<b>Title</b> : """ + experience['title'] + """<br>
				<b>Start Date</b> : """ + experience['start_date'] + """<br>
					<b>End Date</b> : """ + end_date + """<br>
				<b>Description</b> : """ + experience['description'][:100] + """...<br>
				<p>
					<a class="text-secondary" href="/user/remove_experience/?experience_id=""" + experience[
                    'id'] + """">
						<i data-toggle="tooltip" class="far fa-trash-alt" title="Remove">&nbsp&nbsp&nbsp</i>
					</a>
				</p>"""
                my_experience = my_experience + exp_html + "<hr>"

        # education
        my_education = ""
        if not session['education']:
            my_education = my_education + """<a class="text-info">No Education available</a>"""
        else:
            for education in session['education']:
                edu_html = """
				<b>Organization</b> : """ + education['organization']['name'] + """<br>
				<b>Title</b> : """ + education['title'] + """<br>
				<b>Start Date</b> : """ + education['start_date'] + """<br>
				<b>End Date</b> : """ + education['end_date'] + """<br>
				<p>
					<a class="text-secondary" href="/user/remove_education/?education_id=""" + education[
                    'id'] + """">
						<i data-toggle="tooltip" class="far fa-trash-alt" title="Remove">&nbsp&nbsp&nbsp</i>
					</a>
				</p>"""
                my_education = my_education + edu_html + "<hr>"

        # personal
        TOPIC = {
            'firstname': 'Firstname',
            'lastname': 'Lastname',
            'about': 'About',
            'profil_title': 'Title',
            'birthdate': 'Birth Date',
            'contact_email': 'Contact Email',
            'contact_phone': 'Contact Phone',
            'postal_address': 'Postal Address',
            'education': 'Education'
        }
        my_personal = ""
        for topicname in TOPIC.keys():
            if session['personal'][topicname].get('claim_value'):
                text = session['personal'][topicname][
                    'claim_value'] + ' (' + session['personal'][topicname][
                        'privacy'] + ')'
                my_personal += """<b>""" + TOPIC[
                    topicname] + """</b> : """ + text + """<br>"""

        # Alias
        if session['username'] != ns.get_username_from_resolver(
                session['workspace_contract'], mode):
            display_alias = False
            my_access = ""
        else:
            display_alias = True
            my_access = ""
            access_list = ns.get_alias_list(session['workspace_contract'],
                                            mode)
            for access in access_list:
                if access['username'] == session['username']:
                    access_html = """
					<span>""" + session['username'] + """ (logged)
					</span>"""
                else:
                    access_html = """
					<span>""" + access['username'] + """ : """ + access['email'] + """
						<a class="text-secondary" href="/user/remove_access/?alias_to_remove=""" + access[
                        'username'] + """">
							<i data-toggle="tooltip" class="fa fa-trash-o" title="Remove">	</i>
						</a>
					</span>"""
                my_access += access_html + """<br>"""

        # credentials/certificates
        my_certificates = ""
        if not session['all_certificate']:
            my_certificates = my_certificates + """<a class="text-info">No Credential available</a>"""
        else:
            for counter, certificate in enumerate(session['all_certificate'],
                                                  1):
                try:
                    cert_html = """<hr>
					<b>Credential Type</b> : """ + certificate['credentialSubject'][
                        'credentialCategory'].capitalize() + """<br>
					<b>Privacy</b> : """ + certificate['privacy'].capitalize(
                        ) + """ credential<br>
					<b>Issuer name</b> : """ + certificate['credentialSubject'].get(
                            'companyName', 'None').capitalize() + """ <br>
					<b>Issuer DID</b> : """ + certificate['issuer'] + """<br>
					<b>Issuance Date</b> : """ + certificate['proof']['created'] + """<br>"""
                except:
                    cert_html = """<hr>
					<b>#</b> : """ + str(counter) + "<br>"

                cert_html += """<b></b><a href= """ + mode.server + """certificate/?certificate_id=did:talao:""" + mode.BLOCKCHAIN + """:""" + session[
                    'workspace_contract'][2:] + """:document:""" + str(
                        certificate['doc_id']
                    ) + """>Display Credential</a><br>
					<p>
					<a class="text-secondary" href="/user/remove_certificate/?certificate_id=""" + certificate[
                        'id'] + """">
					<i data-toggle="tooltip" class="far fa-trash-alt" title="Remove">&nbsp&nbsp&nbsp</i>
					</a>

					<a class="text-secondary" href=/data/?dataId=""" + certificate['id'] + """:certificate>
					<i data-toggle="tooltip" class="fa fa-search-plus" title="Credential data">&nbsp&nbsp&nbsp</i>
					</a>

					<a class="text-secondary" onclick="copyToClipboard('#p""" + str(
                            counter
                        ) + """')">
					<i data-toggle="tooltip" class="fa fa-clipboard" title="Copy Credential Link">&nbsp&nbsp&nbsp</i>
					</a>

					<a class="text-secondary" href=/user/swap_privacy/?certificate_id=""" + certificate[
                            'id'] + """&privacy=""" + certificate['privacy'] + """>
					<i data-toggle="tooltip" title="Change privacy" class="fas fa-redo" >&nbsp&nbsp&nbsp</i>
					</a>

					</p>
					<p hidden id="p""" + str(
                                counter
                            ) + """" >""" + mode.server + """guest/certificate/?certificate_id=did:talao:""" + mode.BLOCKCHAIN + """:""" + session[
                                'workspace_contract'][
                                    2:] + """:document:""" + str(
                                        certificate['doc_id']) + """</p>"""
                my_certificates += cert_html

        return render_template('person_identity.html',
                               **session['menu'],
                               display_alias=display_alias,
                               personal=my_personal,
                               experience=my_experience,
                               education=my_education,
                               skills=my_skills,
                               certificates=my_certificates,
                               access=my_access,
                               partner=my_partner,
                               issuer=my_issuer,
                               digitalvault=my_file,
                               nb_certificates=len(session['all_certificate']))
    # specific to company
    if session['type'] == 'company':

        # init employee table
        employee = company.Employee(session['host'], mode)

        # Admin list  and add admin
        my_admin_start = """<a href="/company/add_employee/?role_to_add=admin">Add an Admin</a><hr> """
        my_admins = ""
        admin_list = employee.get_list('admin', 'all')
        for admin in admin_list:
            admin_html = """
				<span>""" + admin['username'] + """ => """ + admin['identity_name'] + """
				<a class="text-secondary" href="/user/remove_access/?employee_to_remove=""" + admin[
                'username'] + """">
					<i data-toggle="tooltip" class="fas fa-trash-alt" title="Remove">	</i>
				</a>
				</span>"""
            my_admins += admin_html + """<br>"""
        my_admins = my_admin_start + my_admins

        # Issuer list and add issuer within a company
        my_managers_start = """<a href="/company/add_employee/?role_to_add=issuer">Add an Issuer</a><hr> """
        my_managers = ""
        manager_list = employee.get_list('issuer', 'all')
        for manager in manager_list:
            manager_html = """
				<span>""" + manager['username'] + """ => """ + manager[
                'identity_name'] + """
				<a class="text-secondary" href="/user/remove_access/?employee_to_remove=""" + manager[
                    'username'] + """">
					<i data-toggle="tooltip" class="fas fa-trash-alt" title="Remove">	</i>
				</a>
				</span>"""
            my_managers += manager_html + """<br>"""
        my_managers = my_managers_start + my_managers

        # Reviewer list and add reviewers
        my_reviewers_start = """<a href="/company/add_employee/?role_to_add=reviewer">Add a Reviewer</a><hr> """
        my_reviewers = ""
        reviewer_list = employee.get_list('reviewer', 'all')
        for reviewer in reviewer_list:
            reviewer_html = """
				<span>""" + reviewer['username'] + """ => """ + reviewer[
                'identity_name'] + """
				<a class="text-secondary" href="/user/remove_access/?employee_to_remove=""" + reviewer[
                    'username'] + """">
					<i data-toggle="tooltip" class="fas fa-trash-alt" title="Remove">	</i>
				</a>
				</span>"""
            my_reviewers += reviewer_html + """<br>"""
        my_reviewers = my_reviewers_start + my_reviewers

        # Company campaigns
        if session['role'] not in ['issuer', 'reviewer']:
            my_campaign = """<a href="/company/add_campaign/">Add a Campaign</a><hr> """
        else:
            my_campaign = ""
        campaign = company.Campaign(session['host'], mode)
        campaign_list = campaign.get_list()
        if campaign_list:
            for camp in campaign_list:
                try:
                    description = json.loads(
                        camp['description'])['description']
                except:
                    description = camp.get('description', 'unkown')
                campaign_html = camp.get(
                    'campaign_name', 'unknown') + """ : """ + description[:100]
                remove_option = """...
				<a class="text-secondary" href="/company/remove_campaign/?campaign_name=""" + camp.get(
                    'campaign_name', 'unkown') + """">
					<i data-toggle="tooltip" class="fas fa-trash-alt" title="Remove">	</i>
				</a>"""
                if session['role'] not in ['issuer', 'reviewer']:
                    campaign_html += remove_option
                my_campaign += campaign_html + "<hr>"

        # company settings
        if session['role'] in ['creator', 'admin']:
            my_personal = """<a href="/user/picture/">Change Logo</a><br>
						<a href="/user/signature/">Change Signature</a><br>"""
        else:
            my_personal = ""

        for topicname in COMPANY_TOPIC:
            if session['personal'][topicname]['claim_value']:
                topicname_value = session['personal'][topicname]['claim_value']
                topicname_privacy = ' (' + session['personal'][topicname][
                    'privacy'] + ')'
                my_personal = my_personal + """
				<span><b>""" + topicname + """</b> : """ + topicname_value + topicname_privacy + """
				</span><br>"""
        if session['role'] in ['creator', 'admin']:
            my_personal = my_personal + """<a href="/user/update_company_settings/">Update Company Data</a>"""

        # credentials
        if not session['all_certificate']:
            my_certificates = """<a class="text-info">No Credentials available</a>"""
        else:
            my_certificates = """<div  style="height:300px;overflow:auto;overflow-x: hidden;">"""
            for counter, certificate in enumerate(session['all_certificate'],
                                                  1):
                if '@context' in certificate:
                    if certificate['credentialSubject'][
                            'credentialCategory'] == "reference":
                        cert_html = """<hr>
								<b>Issuer Name</b> : """ + certificate['credentialSubject'][
                            'companyName'] + """<br>
								<b>Certificate Type</b> : """ + certificate['credentialSubject'][
                                'credentialCategory'].capitalize() + """<br>
								<b>Title</b> : """ + certificate['credentialSubject']['offers'][
                                    'title'] + """<br>
								<b>Description</b> : """ + certificate['credentialSubject']['offers'][
                                        'description'] + """<br>
								<b></b><a href= """ + mode.server + """certificate/?certificate_id=did:talao:""" + mode.BLOCKCHAIN + """:""" + session[
                                            'workspace_contract'][
                                                2:] + """:document:""" + str(
                                                    certificate['doc_id']
                                                ) + """>Display Certificate</a><br>
								<p>
								<a class="text-secondary" href="/user/remove_certificate/?certificate_id=""" + certificate[
                                                    'id'] + """">
								<i data-toggle="tooltip" class="far fa-trash-alt" title="Remove">&nbsp&nbsp&nbsp</i>
								</a>

								<a class="text-secondary" href=/data/?dataId=""" + certificate[
                                                        'id'] + """:certificate>
								<i data-toggle="tooltip" class="fa fa-search-plus" title="Data Check">&nbsp&nbsp&nbsp</i>
								</a>

								<a class="text-secondary" onclick="copyToClipboard('#p""" + str(
                                                            counter) + """')">
								<i data-toggle="tooltip" class="fa fa-clipboard" title="Copy Certificate Link"></i>
								</a>
								</p>
								<p hidden id="p""" + str(counter
                                 ) + """" >""" + mode.server + """guest/certificate/?certificate_id=did:talao:""" + mode.BLOCKCHAIN + """:""" + session[
                                     'workspace_contract'][
                                         2:] + """:document:""" + str(
                                             certificate['doc_id']
                                         ) + """</p>"""
                else:
                    cert_html = """<a class="text-secondary" href="/user/remove_certificate/?certificate_id=""" + certificate[
                        'id'] + """">
								<i data-toggle="tooltip" class="far fa-trash-alt" title="Remove">&nbsp&nbsp&nbsp</i>
								</a>

								<a class="text-secondary" href=/data/?dataId=""" + certificate[
                            'id'] + """:certificate>
								<i data-toggle="tooltip" class="fa fa-search-plus" title="Data Check">&nbsp&nbsp&nbsp</i>
								</a>"""
                    logging.warning('incorrect certificate type')
                my_certificates = my_certificates + cert_html
            my_certificates = my_certificates + """</div>"""

        return render_template('company_identity.html',
                               **session['menu'],
                               admin=my_admins,
                               manager=my_managers,
                               reviewer=my_reviewers,
                               personal=my_personal,
                               skills=my_skills,
                               issuer=my_issuer,
                               certificates=my_certificates,
                               company_campaign=my_campaign,
                               digitalvault=my_file)