示例#1
0
def aup():
    """Send the user to Acceptable Use Policy page"""
    # Read AUP from markdown dir
    domain_name = domain_name_edgecase()

    with open(brand_dir + '/' + domain_name + '/signup_content/signup_modal.md', "r") as file:
        aup_md = file.read()
    return render_template('AUP.html', aup_md=aup_md)
示例#2
0
def users_groups():
    """Groups that user's are specifically members of"""
    if request.method == 'GET':
        query = {
            'token': ciconnect_api_token,
            'globus_id': session['primary_identity']
        }
        # Get user info to derive unix name
        user = get_user_info(session)
        unix_name = user['metadata']['unix_name']
        # Get user's group membership info based on session unix name
        users_group_memberships = get_user_group_memberships(
            session, unix_name)

        multiplexJson = {}
        group_membership_status = {}
        for group in users_group_memberships:
            if group['state'] not in ['nonmember']:
                group_name = group['name']
                group_query = "/v1alpha1/groups/" + \
                    group_name + "?token=" + query['token']
                multiplexJson[group_query] = {"method": "GET"}
                group_membership_status[group_query] = group['state']
        # POST request for multiplex return
        multiplex = get_multiplex(multiplexJson)

        users_groups = []
        for group in multiplex:
            if ((session['url_host']['unix_name'] in (json.loads(
                    multiplex[group]['body'])['metadata']['name'])) and
                (len((json.loads(multiplex[group]['body'])['metadata']['name']
                      ).split('.')) > 1)):
                users_groups.append((json.loads(multiplex[group]['body']),
                                     group_membership_status[group]))
        # users_groups = [group for group in users_groups if len(group['name'].split('.')) == 3]

        # Query user's pending project requests
        pending_project_requests = get_user_pending_project_requests(unix_name)
        # Check user's member status of root connect group
        connect_group = session['url_host']['unix_name']
        user_status = get_user_connect_status(unix_name, connect_group)

        domain_name = domain_name_edgecase()

        with open(
                brand_dir + '/' + domain_name +
                "/form_descriptions/group_unix_name_description.md",
                "r") as file:
            group_unix_name_description = file.read()

        return render_template(
            'users_groups.html',
            groups=users_groups,
            project_requests=pending_project_requests,
            user_status=user_status,
            group_unix_name_description=group_unix_name_description)
示例#3
0
def signup():
    """Send the user to Globus Auth with signup=1."""
    domain_name = domain_name_edgecase()

    with open(brand_dir + '/' + domain_name + '/signup_content/signup_modal.md', "r") as file:
        signup_modal_md = file.read()
    with open(brand_dir + '/' + domain_name + '/signup_content/signup_instructions.md', "r") as file:
        signup_instructions_md = file.read()
    with open(brand_dir + '/' + domain_name + '/signup_content/signup.md', "r") as file:
        signup_md = file.read()
    return render_template('signup.html', signup_modal_md=signup_modal_md, signup_instructions_md=signup_instructions_md, signup_md=signup_md)
示例#4
0
def flash_message_parser(route_name):
    
    # domain_name = request.headers['Host']
    # if 'usatlas' in domain_name:
    #     domain_name = 'atlas.ci-connect.net'
    # elif 'uscms' in domain_name:
    #     domain_name = 'cms.ci-connect.net'
    # elif 'uchicago' in domain_name:
    #     domain_name = 'psdconnect.uchicago.edu'
    # elif 'snowmass21' in domain_name:
    #     domain_name = 'snowmass21.ci-connect.net'

    domain_name = domain_name_edgecase()
    # print(domain_name)
    config = configparser.RawConfigParser(allow_no_value=True)
    config.read(brand_dir + '/' + domain_name +
                '/flash_messages/flash_messages.cfg')
    flash_message = config.get('flash_messages', route_name)
    return flash_message
示例#5
0
def home():
    """Home page - play with it if you must!"""
    domain_name = domain_name_edgecase()
    
    with open(brand_dir + '/' + domain_name + '/home_content/home_text_headline.md', "r") as file:
        home_text_headline = file.read()
    with open(brand_dir + '/' + domain_name + '/home_content/home_text_rotating.md', "r") as file:
        home_text_rotating = file.read()

    collaborations = [{'name': 'Atlas',
                       'href': 'https://connect.usatlas.org',
                       'img': 'img/atlas-connect-logo.png',
                       'description': get_about_markdown("atlas.ci-connect.net")},
                      {'name': 'CMS',
                       'href': 'https://connect.uscms.org',
                       'img': 'img/cms-connect-logo.png',
                       'description': get_about_markdown("cms.ci-connect.net")},
                      {'name': 'Duke',
                       'href': 'https://duke.ci-connect.net',
                       'img': 'img/duke-connect-logo.png',
                       'description': get_about_markdown("duke.ci-connect.net")},
                      {'name': 'OSG',
                       'href': 'https://www.osgconnect.net',
                       'img': 'img/osg-connect-logo.png',
                       'description': get_about_markdown("osgconnect.net")},
                      {'name': 'SPT',
                       'href': 'https://spt.ci-connect.net',
                       'img': 'img/spt-connect-logo.png',
                       'description': get_about_markdown("spt.ci-connect.net")},
                      {'name': 'PSD',
                       'href': 'https://psdconnect.uchicago.edu',
                       'img': 'img/psd-connect-logo.png',
                       'description': get_about_markdown("psdconnect.uchicago.edu")},
                      {'name': 'Snowmass21',
                       'href': 'https://connect.snowmass21.io',
                       'img': 'img/snowmass-connect-logo.png',
                       'description': get_about_markdown("snowmass21.ci-connect.net")}]

    return render_template('home.html', home_text_headline=home_text_headline,
                                        home_text_rotating=home_text_rotating,
                                        collaborations=collaborations)
示例#6
0
def profile():
    """User profile information. Assocated with a Globus Auth identity."""
    if request.method == 'GET':
        identity_id = session.get('primary_identity')
        try:
            user = get_user_info(session)
            unix_name = user['metadata']['unix_name']
            profile = get_user_profile(unix_name)
        except:
            profile = None

        if profile:
            print("Found profile: {}".format(profile))
            profile = profile['metadata']
            unix_name = profile['unix_name']
            group_name = session['url_host']['unix_name']
            user_status = get_user_group_status(unix_name, group_name, session)
        else:
            flash(
                'Please complete any missing profile fields and press Save.', 'warning')
            return redirect(url_for('create_profile'))

        if request.args.get('next'):
            session['next'] = get_safe_redirect()

        group_memberships = []
        for group in profile['group_memberships']:
            if ((session['url_host']['unix_name'] in group['name']) and (len(group['name'].split('.')) > 1)):
                group_memberships.append(group)

        domain_name = domain_name_edgecase()

        with open(brand_dir + '/' + domain_name + "/form_descriptions/group_unix_name_description.md", "r") as file:
            group_unix_name_description = file.read()

        return render_template('profile.html', profile=profile,
                               user_status=user_status,
                               group_memberships=group_memberships,
                               group_unix_name_description=group_unix_name_description)
示例#7
0
def about():
    """Send the user to the About page"""
    # Read About from markdown dir
    domain_name = domain_name_edgecase()

    with open(brand_dir + '/' + domain_name + '/about/about.md', "r") as file:
        about = file.read()
    
    organizations = [{'name': 'OSG',
                       'href': 'https://www.osgconnect.net',
                       'img': 'img/osg-org.png',
                       'description': "The OSG is providing a job submission service to the member institutions of the the Open Science Grid which are providing opportunistic CPU resources"},
                      {'name': 'SLATE',
                       'href': 'https://slateci.io/',
                       'img': 'img/slate-org.png',
                       'description': "The SLATE platform is utilized for job submission services"},
                      {'name': 'IRIS-HEP',
                       'href': 'https://iris-hep.org/',
                       'img': 'img/iris-hep-org.png',
                       'description': "The IRIS-HEP Scalable Systems Laboratory provides support for Snowmass21 Connect analysis services"},
                      {'name': 'PSD',
                       'href': 'https://psdconnect.uchicago.edu',
                       'img': 'img/psd-org.png',
                       'description': "The Physical Sciences Division of the University of Chicago is providing IT infrastructure supporting the login service and storage"},
                      {'name': 'MANIAC lab',
                       'href': 'https://maniaclab.uchicago.edu/',
                       'img': 'img/maniac-org.png',
                       'description': "The team at MANIAC Lab provides the CI-Connect service"},
                      {'name': 'Brookhaven National Lab',
                       'href': 'https://www.bnl.gov/world/',
                       'img': 'img/brookhaven_national_lab.jpg',
                       'description': "Brookhaven National Laboratory has pledged to store data from Snowmass21 Monte Carlo simulation activities"},
                      {'name': 'Fermilab',
                       'href': 'https://www.fnal.gov/',
                       'img': 'img/fermilab_plain_logo.jpeg',
                       'description': "Fermilab is pledging storage resources for Snowmass21"}
                      ]
    return render_template('about.html', about=about, organizations=organizations)
示例#8
0
def view_group_email(group_name):
    """View for email form to members"""
    if request.method == 'GET':
        # Get group information
        group = get_group_info(group_name, session)
        # Get User's Group Status
        unix_name = session['unix_name']
        user_status = get_user_group_status(unix_name, group_name, session)
        # Query to return user's enclosing group's membership status
        enclosing_status = get_enclosing_group_status(group_name, unix_name)
        # Query to check user's connect status
        connect_group = session['url_host']['unix_name']
        connect_status = get_user_connect_status(unix_name, connect_group)

        return render_template('group_profile_email.html',
                               group_name=group_name,
                               user_status=user_status,
                               group=group,
                               connect_status=connect_status,
                               enclosing_status=enclosing_status)
    elif request.method == 'POST':
        subject = request.form['subject']
        body = request.form['description']
        try:
            html = request.form['html-enabled']
            body_or_html = "html"
        except:
            body_or_html = "text"

        # mailgun setup here
        domain_name = domain_name_edgecase()
        support_emails = {
            "cms.ci-connect.net": "*****@*****.**",
            "duke.ci-connect.net": "*****@*****.**",
            "spt.ci-connect.net": "*****@*****.**",
            "atlas.ci-connect.net": "*****@*****.**",
            "psdconnect.uchicago.edu": "*****@*****.**",
            "www.ci-connect.net": "*****@*****.**",
            "localhost:5000": "*****@*****.**"
        }

        try:
            support_email = support_emails[domain_name]
        except:
            support_email = "*****@*****.**"

        user_dict, users_statuses = get_group_members_emails(group_name)
        user_emails = [
            user_dict[user]['metadata']['email'] for user in user_dict
        ]
        # print(user_emails)
        r = requests.post(
            "https://api.mailgun.net/v3/api.ci-connect.net/messages",
            auth=('api', mailgun_api_token),
            data={
                "from": "<" + support_email + ">",
                "to": [support_email],
                "bcc": user_emails,
                "subject": subject,
                body_or_html: body,
            })
        if r.status_code == requests.codes.ok:
            flash("Your message has been sent to the members of this group",
                  'success')
            return redirect(url_for('view_group_email', group_name=group_name))
        else:
            flash("Unable to send message: {}".format(r.json()), 'warning')
            return redirect(url_for('view_group_email', group_name=group_name))