Exemplo n.º 1
0
def gm_mail_home(request, template="messaging/mail_home.html"):
    if not request.user.is_superuser: raise Http404
    context = {
        'special_mailboxes': Mailbox.objects.filter(public=True, type=0).order_by('name'),
        'char_mailboxes': Mailbox.objects.filter(public=True, type=1).order_by('name'),
        'group_mailboxes': Mailbox.objects.filter(public=True, type=2).order_by('name'),
        'send_mailboxes': Mailbox.objects.all(),
        'read_mailboxes': Mailbox.objects.all()
    }
    if request.method == 'POST':
        try:
            context['mail_text'] = request.POST.get('text')
            new_mail = Message()
            new_mail.sender = Mailbox.objects.get(code=request.POST.get('from_code'))
            try:
                new_mail.to = Mailbox.objects.get(code=request.POST.get('to_code'))
            except Mailbox.DoesNotExist:
                try:
                    new_mail.to = Mailbox.objects.get(name=request.POST.get('to_name'))
                except Mailbox.DoesNotExist:
                    raise ValidationError("That mailbox doesn't exist.")
            new_mail.text = request.POST.get('text')
            new_mail.subject = request.POST.get('subject')
            print request.POST.get('anon') == 'on'
            new_mail.anon = request.POST.get('anon') == 'on'
            new_mail.save()
            subprocess.Popen(['zwrite', '-d', '-c', 'consortium-sekrit-auto', '-m', "Mail from %s to %s\nSubject: %s\n%s" % (new_mail.sender.name,
                              new_mail.to.name, new_mail.subject, new_mail.text.replace('"', "'"))])
            messages.success(request, "Sent mail to %s" % new_mail.to.name)
            context['mail_text'] = ''
        except ValidationError, e:
            messages.error(request, e.messages[0])
Exemplo n.º 2
0
def mail_home(request, template="messaging/mail_home.html"):
    char = gtc(request)
    context = {
        # 'special_mailboxes': Mailbox.objects.filter(public=True, type=0).order_by('name'),
        'char_mailboxes':
        Mailbox.objects.filter(public=True, type=1).order_by('name'),
        'group_mailboxes':
        Mailbox.objects.filter(public=True, type=2).order_by('name'),
        'send_mailboxes':
        Mailbox.objects.filter(
            Q(character=char)
            | Q(line__lineorder__order=1, line__lineorder__character=char)).
        order_by('type'),
        'read_mailboxes':
        Mailbox.objects.filter(
            Q(character=char) | Q(line__lineorder__character=char))
    }
    if request.method == 'POST':
        try:
            context['mail_text'] = request.POST.get('text')
            new_mail = Message()
            new_mail.sender = Mailbox.objects.get(
                code=request.POST.get('from_code'))
            try:
                new_mail.to = Mailbox.objects.get(
                    code=request.POST.get('to_code'))
            except Mailbox.DoesNotExist:
                try:
                    new_mail.to = Mailbox.objects.get(
                        name=request.POST.get('to_name'))
                except Mailbox.DoesNotExist:
                    raise ValidationError("That mailbox doesn't exist.")
            new_mail.text = request.POST.get('text')
            new_mail.subject = request.POST.get('subject')
            new_mail.anon = request.POST.get('anon') == 'on'
            new_mail.save()
            if new_mail.anon:
                check_inspiration(request)
            try:
                subprocess.Popen([
                    'zwrite', '-d', '-c', 'consortium-sekrit-auto', '-m',
                    "Mail from %s to %s\nSubject: %s\n%s" %
                    (new_mail.sender.name, new_mail.to.name, new_mail.subject,
                     new_mail.text.replace('"', "'"))
                ])
            except:
                pass
            messages.success(request, "Sent mail to %s" % new_mail.to.name)
            context['mail_text'] = ''
        except ValidationError, e:
            messages.error(request, e.messages[0])
Exemplo n.º 3
0
def gm_mail_home(request, template="messaging/mail_home.html"):
    if not request.user.is_superuser: raise Http404
    context = {
        'special_mailboxes':
        Mailbox.objects.filter(public=True, type=0).order_by('name'),
        'char_mailboxes':
        Mailbox.objects.filter(public=True, type=1).order_by('name'),
        'group_mailboxes':
        Mailbox.objects.filter(public=True, type=2).order_by('name'),
        'send_mailboxes':
        Mailbox.objects.all(),
        'read_mailboxes':
        Mailbox.objects.all()
    }
    if request.method == 'POST':
        try:
            context['mail_text'] = request.POST.get('text')
            new_mail = Message()
            new_mail.sender = Mailbox.objects.get(
                code=request.POST.get('from_code'))
            try:
                new_mail.to = Mailbox.objects.get(
                    code=request.POST.get('to_code'))
            except Mailbox.DoesNotExist:
                try:
                    new_mail.to = Mailbox.objects.get(
                        name=request.POST.get('to_name'))
                except Mailbox.DoesNotExist:
                    raise ValidationError("That mailbox doesn't exist.")
            new_mail.text = request.POST.get('text')
            new_mail.subject = request.POST.get('subject')
            print request.POST.get('anon') == 'on'
            new_mail.anon = request.POST.get('anon') == 'on'
            new_mail.save()
            subprocess.Popen([
                'zwrite', '-d', '-c', 'consortium-sekrit-auto', '-m',
                "Mail from %s to %s\nSubject: %s\n%s" %
                (new_mail.sender.name, new_mail.to.name, new_mail.subject,
                 new_mail.text.replace('"', "'"))
            ])
            messages.success(request, "Sent mail to %s" % new_mail.to.name)
            context['mail_text'] = ''
        except ValidationError, e:
            messages.error(request, e.messages[0])
Exemplo n.º 4
0
def mail_home(request, template="messaging/mail_home.html"):
    char = gtc(request)
    context = {
        # 'special_mailboxes': Mailbox.objects.filter(public=True, type=0).order_by('name'),
        'char_mailboxes': Mailbox.objects.filter(public=True, type=1).order_by('name'),
        'group_mailboxes': Mailbox.objects.filter(public=True, type=2).order_by('name'),
        'send_mailboxes': Mailbox.objects.filter(Q(character=char) | Q(line__lineorder__order=1, line__lineorder__character=char)).order_by('type'),
        'read_mailboxes': Mailbox.objects.filter(Q(character=char) | Q(line__lineorder__character=char))

    }
    if request.method == 'POST':
        try:
            context['mail_text'] = request.POST.get('text')
            new_mail = Message()
            new_mail.sender = Mailbox.objects.get(code=request.POST.get('from_code'))
            try:
                new_mail.to = Mailbox.objects.get(code=request.POST.get('to_code'))
            except Mailbox.DoesNotExist:
                try:
                    new_mail.to = Mailbox.objects.get(name=request.POST.get('to_name'))
                except Mailbox.DoesNotExist:
                    raise ValidationError("That mailbox doesn't exist.")
            new_mail.text = request.POST.get('text')
            new_mail.subject = request.POST.get('subject')
            new_mail.anon = request.POST.get('anon') == 'on'
            new_mail.save()
            if new_mail.anon:
                check_inspiration(request)
            try:
                subprocess.Popen(['zwrite', '-d', '-c', 'consortium-sekrit-auto', '-m', "Mail from %s to %s\nSubject: %s\n%s" % (new_mail.sender.name,
                new_mail.to.name, new_mail.subject, new_mail.text.replace('"', "'"))])
            except:
                pass
            messages.success(request, "Sent mail to %s" % new_mail.to.name)
            context['mail_text'] = ''
        except ValidationError, e:
            messages.error(request, e.messages[0])