Ejemplo n.º 1
0
def jabber_broadcast_view(request):
    success = False
    if request.method == 'POST':
        form = JabberBroadcastForm(request.POST)
        if form.is_valid():
            user_info = AuthServicesInfo.objects.get(user=request.user)
            main_char = EveCharacter.objects.get(character_id=user_info.main_char_id)
            if user_info.main_char_id != "":
                message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + main_char.character_name + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,)

            else:
                message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,)

            success = True
    else:
        form = JabberBroadcastForm()

    context = {'form': form, 'success': success}
    return render_to_response('registered/jabberbroadcast.html', context, context_instance=RequestContext(request))
Ejemplo n.º 2
0
def jabber_broadcast_view(request):
    success = False
    if request.method == 'POST':
        form = JabberBroadcastForm(request.POST)
        if form.is_valid():
            JabberManager.send_broadcast_message(form.cleaned_data['group'], form.cleaned_data['message'])
            success = True
    else:
        form = JabberBroadcastForm()

    context = {'form': form, 'success': success}
    return render_to_response('registered/jabberbroadcast.html', context, context_instance=RequestContext(request))
Ejemplo n.º 3
0
def jabber_broadcast_view(request):
    success = False
    if request.method == 'POST':
        form = JabberBroadcastForm(request.POST)
        if form.is_valid():
            user_info = AuthServicesInfo.objects.get(user=request.user)
            main_char = EveCharacter.objects.get(
                character_id=user_info.main_char_id)
            if user_info.main_char_id != "":
                message_to_send = form.cleaned_data[
                    'message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + main_char.character_name + " TO: " + form.cleaned_data[
                        'group'] + " WHEN: " + datetime.datetime.utcnow(
                        ).strftime(
                            "%Y-%m-%d %H:%M:%S"
                        ) + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(
                    group_to_send,
                    message_to_send,
                )

            else:
                message_to_send = form.cleaned_data[
                    'message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + form.cleaned_data[
                        'group'] + " WHEN: " + datetime.datetime.utcnow(
                        ).strftime(
                            "%Y-%m-%d %H:%M:%S"
                        ) + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(
                    group_to_send,
                    message_to_send,
                )

            success = True
    else:
        form = JabberBroadcastForm()

    context = {'form': form, 'success': success}
    return render_to_response('registered/jabberbroadcast.html',
                              context,
                              context_instance=RequestContext(request))
Ejemplo n.º 4
0
def jabber_broadcast_view(request):
    logger.debug("jabber_broadcast_view called by user %s" % request.user)
    success = False
    allchoices = []
    if check_if_user_has_permission(request.user, 'jabber_broadcast_all'):
        allchoices.append(('all', 'all'))
        for g in Group.objects.all():
            allchoices.append((str(g.name), str(g.name)))
    else:
        for g in request.user.groups.all():
            allchoices.append((str(g.name), str(g.name)))
    if request.method == 'POST':
        form = JabberBroadcastForm(request.POST)
        form.fields['group'].choices = allchoices
        logger.debug("Received POST request containing form, valid: %s" % form.is_valid())
        if form.is_valid():
            user_info = AuthServicesInfo.objects.get(user=request.user)
            main_char = EveCharacter.objects.get(character_id=user_info.main_char_id)
            logger.debug("Processing jabber broadcast for user %s with main character %s" % (user_info, main_char))
            if user_info.main_char_id != "":
                message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + main_char.character_name + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,)

            else:
                message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,)

            success = True
            logger.info("Sent jabber broadcast on behalf of user %s" % request.user)
    else:
        form = JabberBroadcastForm()
        form.fields['group'].choices = allchoices
        logger.debug("Generated broadcast form for user %s containing %s groups" % (request.user, len(form.fields['group'].choices)))

    context = {'form': form, 'success': success}
    return render_to_response('registered/jabberbroadcast.html', context, context_instance=RequestContext(request))
Ejemplo n.º 5
0
def jabber_broadcast_view(request):
    logger.debug("jabber_broadcast_view called by user %s" % request.user)
    success = False
    allchoices = []
    if check_if_user_has_permission(request.user, 'jabber_broadcast_all'):
        allchoices.append(('all', 'all'))
        for g in Group.objects.all():
            allchoices.append((str(g.name), str(g.name)))
    else:
        for g in request.user.groups.all():
            allchoices.append((str(g.name), str(g.name)))
    if request.method == 'POST':
        form = JabberBroadcastForm(request.POST)
        form.fields['group'].choices = allchoices
        logger.debug("Received POST request containing form, valid: %s" % form.is_valid())
        if form.is_valid():
            user_info = AuthServicesInfo.objects.get(user=request.user)
            main_char = EveCharacter.objects.get(character_id=user_info.main_char_id)
            logger.debug("Processing jabber broadcast for user %s with main character %s" % (user_info, main_char))
            if user_info.main_char_id != "":
                message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "[" + main_char.corporation_ticker + "]" + main_char.character_name + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,)

            else:
                message_to_send = form.cleaned_data['message'] + "\n##### SENT BY: " + "No character but can send pings?" + " TO: " + form.cleaned_data['group'] + " WHEN: " + datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") + " #####\n##### Replies are NOT monitored #####\n"
                group_to_send = form.cleaned_data['group']

                OpenfireManager.send_broadcast_threaded(group_to_send, message_to_send,)

            success = True
            logger.info("Sent jabber broadcast on behalf of user %s" % request.user)
    else:
        form = JabberBroadcastForm()
        form.fields['group'].choices = allchoices
        logger.debug("Generated broadcast form for user %s containing %s groups" % (request.user, len(form.fields['group'].choices)))

    context = {'form': form, 'success': success}
    return render_to_response('registered/jabberbroadcast.html', context, context_instance=RequestContext(request))