Ejemplo n.º 1
0
def registration(request):
    if request.method == 'POST':  # If the form has been submitted...
        form = UserRegistrationForm(request.POST)
        if form.is_valid():  # All validation rules pass
            # create user from cleaned_data
            username = form.cleaned_data['username']
            email = form.cleaned_data['email']
            password = form.cleaned_data['password1']

            new_user = User.objects.create_user(username, email, password)
            new_user.is_active = False  # Users created inactive by default

            # Add users to ionusers group, for a default set of permissions
            try:
                group = Group.objects.get(name='ionusers')
                new_user.groups.add(group)
            except Group.DoesNotExist:
                logger.warn("Group ionusers not found. " +
                         "New user %s will lack permission to do anything beyond look!", username)
            new_user.save()

            # Send global message notifying of pending registration
            msg = "New pending user registration for '%s'. " + \
                "Please visit <a href='%s'>Account Management</a> (as an admin user) to review."
            Message.warn(msg % (username, urlresolvers.reverse('configure_account')))

            # Otherwise redirect to a success page. Awaiting approval
            return shortcuts.redirect(urlresolvers.reverse('signup_pending'))
    else:
        # Blank Form
        form = UserRegistrationForm()

    context = template.RequestContext(request, {'form': form, })
    return shortcuts.render_to_response("rundb/login/ion_account_reg.html",
                                        context_instance=context)
Ejemplo n.º 2
0
def registration(request):
    if request.method == 'POST':  # If the form has been submitted...
        form = UserRegistrationForm(request.POST)
        if form.is_valid():  # All validation rules pass
            # create user from cleaned_data
            username = form.cleaned_data['username']
            email = form.cleaned_data['email']
            password = form.cleaned_data['password1']

            new_user = User.objects.create_user(username, email, password)
            new_user.is_active = False  # Users created inactive by default

            # Add users to ionusers group, for a default set of permissions
            try:
                group = Group.objects.get(name='ionusers')
                new_user.groups.add(group)
            except Group.DoesNotExist:
                logger.warn("Group ionusers not found. " +
                         "New user %s will lack permission to do anything beyond look!", username)
            new_user.save()

            # Send global message notifying of pending registration
            msg = "New pending user registration for '%s'. " + \
                "Please visit <a href='%s'>Account Management</a> (as an admin user) to review."
            Message.warn(msg % (username, urlresolvers.reverse('configure_account')))

            # Otherwise redirect to a success page. Awaiting approval
            return shortcuts.redirect(urlresolvers.reverse('signup_pending'))
    else:
        # Blank Form
        form = UserRegistrationForm()

    context = template.RequestContext(request, {'form': form, })
    return shortcuts.render_to_response("rundb/login/ion_account_reg.html",
                                        context_instance=context)
Ejemplo n.º 3
0
def update_banner(alerts):
    new = False
    # update message banner
    message = Message.objects.filter(tags="service_status_alert")
    if len(alerts) > 0:
        msg = 'ALERT system services are down: %s. ' % ', '.join(alerts)
        msg += ' Please contact your system administrator for assistance.'
        if not message or message[0].body != msg:
            message.delete()
            Message.warn(msg, tags="service_status_alert")
            new = True
    else:
        message.delete()
    print '...updated message banner'
    return new
Ejemplo n.º 4
0
def update_banner(alerts):
    new = False
    # update message banner
    message = Message.objects.filter(tags="service_status_alert")
    if len(alerts) > 0:
        msg = 'ALERT system services are down: %s. ' % ', '.join(alerts)
        msg += ' Please contact your system administrator for assistance.'
        if not message or message[0].body != msg:
            message.delete()
            Message.warn(msg, tags="service_status_alert")
            new = True
    else:
        message.delete()
    print '...updated message banner'
    return new
Ejemplo n.º 5
0
Archivo: views.py Proyecto: zjwang6/TS
def registration(request):
    if request.method == "POST":  # If the form has been submitted...
        form = UserRegistrationForm(request.POST)
        if form.is_valid():  # All validation rules pass
            # create user from cleaned_data
            username = form.cleaned_data["username"]
            email = form.cleaned_data["email"]
            password = form.cleaned_data["password1"]

            new_user = User.objects.create_user(username, email, password)
            new_user.is_active = False  # Users created inactive by default

            # Add users to ionusers group, for a default set of permissions
            try:
                group = Group.objects.get(name="ionusers")
                new_user.groups.add(group)
            except Group.DoesNotExist:
                logger.warn(
                    "Group ionusers not found. " +
                    "New user %s will lack permission to do anything beyond look!",
                    username,
                )
            new_user.save()

            # update UserProfile to indicate this account needs activation
            new_user.userprofile.needs_activation = True
            new_user.userprofile.save()

            # Send global message notifying of pending registration
            msg = (
                "New pending user registration for '%s'. " +
                "Please visit <a href='%s'>Account Management</a> to review."
            )  # TODO: i18n ?
            Message.warn(
                msg % (username, urlresolvers.reverse("configure_account")),
                route=Message.USER_STAFF,
            )

            # Otherwise redirect to a success page. Awaiting approval
            return shortcuts.redirect(urlresolvers.reverse("signup_pending"))
    else:
        # Blank Form
        form = UserRegistrationForm()

    context = template.RequestContext(request, {"form": form})
    return shortcuts.render_to_response("rundb/login/ion_account_reg.html",
                                        context_instance=context)
Ejemplo n.º 6
0
Archivo: tasks.py Proyecto: LBragg/TS
def check_raid_status():
    # check RAID state and alert user with message banner of any problems
    from iondb.rundb.models import Message

    async_result = get_raid_stats_json.apply_async(queue="periodic")
    raidinfo = async_result.get(timeout=600)
    if async_result.failed():
        logger.debug("Failed getting RAID info.")
        return

    raid_status = raid_utils.get_raid_status(raidinfo)
    if len(raid_status) > 0:
        message = Message.objects.filter(tags="raid_alert")
        # show alert for primary internal storage RAID
        if raid_utils.ERROR in [r.get('status') for r in raid_status]:
            if not message:
                msg = 'WARNING: RAID storage disk error.'
                golink = "<a href='%s' >  Visit Services Tab  </a>" % ('/configure/services/')
                Message.warn(msg+"   %s" % golink,tags="raid_alert")
        else:
            message.delete()