Example #1
0
def send_team_admin_email(request, admin_id):
    """
    Renders simple page for emailing the a Team admin
    :param request: any request
    :param admin_id: a valid id of a TeamAdministrator object
    :return: a very simple form
    """
    admin = TeamAdministrator.objects.get(id=admin_id)
    profile = name = email = ""

    if admin.entity_type == 'fan':
        profile = "/fan/%s" % admin.entity_id
        fan = FanPage.objects.get(id=admin.entity_id)
        name = fan_page_name(fan)
        email = fan.fan.email
    elif admin.entity_type == 'student':
        profile = "/cern/student/%s" % admin.entity_id
        stu = Student.objects.get(id=admin.entity_id)
        name = user_name(stu.user) or stu.display_name or 'No Name'
        email = student_email(stu)

    return render_to_response('spudderadmin/pages/reports/send_email.html', {
        'profile': profile,
        'name': name,
        'email': email
    },
                              context_instance=RequestContext(request))
Example #2
0
def send_team_admin_email(request, admin_id):
    """
    Renders simple page for emailing the a Team admin
    :param request: any request
    :param admin_id: a valid id of a TeamAdministrator object
    :return: a very simple form
    """
    admin = TeamAdministrator.objects.get(id=admin_id)
    profile = name = email = ""

    if admin.entity_type == 'fan':
        profile = "/fan/%s" % admin.entity_id
        fan = FanPage.objects.get(id=admin.entity_id)
        name = fan_page_name(fan)
        email = fan.fan.email
    elif admin.entity_type == 'student':
        profile = "/cern/student/%s" % admin.entity_id
        stu = Student.objects.get(id=admin.entity_id)
        name = user_name(stu.user) or stu.display_name or 'No Name'
        email = student_email(stu)

    return render_to_response('spudderadmin/pages/reports/send_email.html',
                              {
                                  'profile': profile,
                                  'name': name,
                                  'email': email
                              },
                              context_instance=RequestContext(request))
def get_team_admin_name(team_admin):
    """
    Gets name for the entity of TeamAdministrator object
    :param team_admin: any TeamAdmininstrator object
    :return: a name as string
    """
    if team_admin.entity_type == 'fan':
        return fan_page_name(FanPage.objects.get(id=team_admin.entity_id))
    elif team_admin.entity_type == 'student':
        return user_name(Student.objects.get(id=team_admin.entity_id).user)
Example #4
0
def follow(request):
    """
    A page allowing the Fan to create a custom #tag for entity
    :param request: a GET request
    :return: a single well with form for entity #tag, or an
        HTTPResponseNotAllowed
    """
    if request.method == 'GET':
        origin = str(request.GET.get('origin', ''))
        name = tag = base_well_url = base_quote_url = None
        fan_tags = FanFollowingEntityTag.objects.filter(fan=request.current_role.entity)

        if re.match(r'/venues/view/\d+', origin):
            ven = Venue.objects.get(id=str.split(origin, '/')[-1])
            name = ven.aka_name
            tag = ven.name
            base_well_url = 'spuddercern/base_single_well.html'
            base_quote_url = 'spuddercern/quote_messages/base_quote_message.html'

        elif re.match(r'/fan/\d+', origin):
            fan = FanPage.objects.get(id=str.split(origin, '/')[-1])
            name = fan_page_name(fan)
            tag = name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'

        elif re.match(r'/team/\d+/admins', origin):
            team = TeamPage.objects.get(id=str.split(origin, '/')[2])
            name = team.name
            tag = team.at_name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'
            origin = "/team/%s" % team.id
            messages.success(
                request,
                "<h4><i class='fa fa-check'></i> You accepted the invitation to become an administrator</h4>"
                "<p>You are now and administrator of %s, please create a custom #tag</p>" % team.name)

        elif re.match(r'/team/\d+', origin):
            team = TeamPage.objects.get(id=str.split(origin, '/')[-1])
            name = team.name
            tag = team.at_name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'

        elif re.match(r'/team/create', origin):
            team = TeamPage.objects.get(id=request.GET.get('team_id'))
            name = team.name
            tag = team.at_name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'
            origin = "/team/%s" % team.id
            messages.success(
                request,
                "<h4><i class='fa fa-check'></i> Team %s successfully created!</h4>"
                "<p>You successfully create your new team, now please give them a custom #tag</p>" % team.name)

        elif origin == 'invitation':
            invitation_id = request.session.get('invitation_id')
            if invitation_id:
                origin = '/fan/%s/edit?new_registration=true' % request.current_role.entity.id
                try:
                    invitation = Invitation.objects.get(id=invitation_id)
                    if invitation.invitation_type == Invitation.REGISTER_AND_ADMINISTRATE_TEAM_INVITATION:
                        team = TeamPage.objects.get(id=invitation.target_entity_id)
                        name = team.name
                        tag = team.at_name
                        base_well_url = 'spudderspuds/base_single_well.html'
                        base_quote_url = 'spudderspuds/components/base_quote_message.html'
                        messages.success(
                            request,
                            "<h4><i class='fa fa-check'></i> You accepted the invitation to become an administrator</h4>"
                            "<p>You are now and administrator of %s, please create a custom #tag</p>" % team.name)
                    else:
                        raise Invitation.DoesNotExist()
                except Invitation.DoesNotExist:
                    return HttpResponseRedirect(origin)

        template_data = {
            'name': name,
            'tag': tag,
            'base_well_url': base_well_url,
            'base_quote_url': base_quote_url,
            'origin': origin,
            'fan_tags': fan_tags}
        return render(request, 'components/sharedpages/following/start_following.html', template_data)

    else:
        return HttpResponseNotAllowed(['GET'])
Example #5
0
def follow(request):
    """
    A page allowing the Fan to create a custom #tag for entity
    :param request: a GET request
    :return: a single well with form for entity #tag, or an
        HTTPResponseNotAllowed
    """
    if request.method == 'GET':
        origin = str(request.GET.get('origin', ''))
        name = tag = base_well_url = base_quote_url = None
        fan_tags = FanFollowingEntityTag.objects.filter(
            fan=request.current_role.entity)

        if re.match(r'/venues/view/\d+', origin):
            ven = Venue.objects.get(id=str.split(origin, '/')[-1])
            name = ven.aka_name
            tag = ven.name
            base_well_url = 'spuddercern/base_single_well.html'
            base_quote_url = 'spuddercern/quote_messages/base_quote_message.html'

        elif re.match(r'/fan/\d+', origin):
            fan = FanPage.objects.get(id=str.split(origin, '/')[-1])
            name = fan_page_name(fan)
            tag = name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'

        elif re.match(r'/team/\d+/admins', origin):
            team = TeamPage.objects.get(id=str.split(origin, '/')[2])
            name = team.name
            tag = team.at_name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'
            origin = "/team/%s" % team.id
            messages.success(
                request,
                "<h4><i class='fa fa-check'></i> You accepted the invitation to become an administrator</h4>"
                "<p>You are now and administrator of %s, please create a custom #tag</p>"
                % team.name)

        elif re.match(r'/team/\d+', origin):
            team = TeamPage.objects.get(id=str.split(origin, '/')[-1])
            name = team.name
            tag = team.at_name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'

        elif re.match(r'/team/create', origin):
            team = TeamPage.objects.get(id=request.GET.get('team_id'))
            name = team.name
            tag = team.at_name
            base_well_url = 'spudderspuds/base_single_well.html'
            base_quote_url = 'spudderspuds/components/base_quote_message.html'
            origin = "/team/%s" % team.id
            messages.success(
                request,
                "<h4><i class='fa fa-check'></i> Team %s successfully created!</h4>"
                "<p>You successfully create your new team, now please give them a custom #tag</p>"
                % team.name)

        elif origin == 'invitation':
            invitation_id = request.session.get('invitation_id')
            if invitation_id:
                origin = '/fan/%s/edit?new_registration=true' % request.current_role.entity.id
                try:
                    invitation = Invitation.objects.get(id=invitation_id)
                    if invitation.invitation_type == Invitation.REGISTER_AND_ADMINISTRATE_TEAM_INVITATION:
                        team = TeamPage.objects.get(
                            id=invitation.target_entity_id)
                        name = team.name
                        tag = team.at_name
                        base_well_url = 'spudderspuds/base_single_well.html'
                        base_quote_url = 'spudderspuds/components/base_quote_message.html'
                        messages.success(
                            request,
                            "<h4><i class='fa fa-check'></i> You accepted the invitation to become an administrator</h4>"
                            "<p>You are now and administrator of %s, please create a custom #tag</p>"
                            % team.name)
                    else:
                        raise Invitation.DoesNotExist()
                except Invitation.DoesNotExist:
                    return HttpResponseRedirect(origin)

        template_data = {
            'name': name,
            'tag': tag,
            'base_well_url': base_well_url,
            'base_quote_url': base_quote_url,
            'origin': origin,
            'fan_tags': fan_tags
        }
        return render(request,
                      'components/sharedpages/following/start_following.html',
                      template_data)

    else:
        return HttpResponseNotAllowed(['GET'])