Beispiel #1
0
def display_main_page(request):
    events = Event.future.get_n(5)
    changes = Change.objects.order_by('-updated')[:5]
    projects = Project.all.order_by('-created_at')[:5]
    randommembers = list(get_active_members().exclude(contactinfo__image="")\
                                                            .order_by('?')[:7])
    herelist = get_herelist()

    # old "isis always on the main page"-hack
    #try:
    #    isis = User.objects.get(username="******")
    #    if not isis in randommembers:
    #        randommembers[0] = User.objects.get(username="******")
    #        random.shuffle(randommembers)
    #except:
    #    pass

    path = os.path.join(settings._DIRNAME, "media/gallerypics/")
    image_urls = gallery_images(path)
    random.shuffle(image_urls)
    image_urls = image_urls[:2]
    images = flickr_images(image_urls)

    return render_to_response('index.html', {
        'event_error_id': ' ',
        'latestevents': events,
        'latestchanges': changes,
        'latestprojects': projects,
        'images': images,
        'randommembers': randommembers,
    },
                              context_instance=RequestContext(
                                  request, processors=[custom_settings_main]))
Beispiel #2
0
def display_main_page(request):
    events = Event.future.get_n(5)
    changes = Change.objects.order_by('-updated')[:5]
    projects = Project.all.order_by('-created_at')[:5]
    randommembers = list(get_active_members().exclude(contactinfo__image="")\
                                                            .order_by('?')[:7])
    herelist = get_herelist()

    # old "isis always on the main page"-hack
    #try:
    #    isis = User.objects.get(username="******")
    #    if not isis in randommembers:
    #        randommembers[0] = User.objects.get(username="******")
    #        random.shuffle(randommembers)
    #except:
    #    pass

    path = os.path.join(settings._DIRNAME, "media/gallerypics/")
    image_urls = gallery_images(path)
    random.shuffle(image_urls)
    image_urls = image_urls[:2]
    images = flickr_images(image_urls)

    return render_to_response('index.html', {
        'event_error_id': ' ',
        'latestevents': events,
        'latestchanges': changes,
        'latestprojects': projects,
        'images': images,
        'randommembers': randommembers,
        }, context_instance=RequestContext(request,
                                           processors=[custom_settings_main]))
Beispiel #3
0
def announce(request):
    print 'wtf:' + repr(request.user)
    form = AnnouncementForm(request.POST or None)
    if not request.POST or not form.is_valid():
        return render_to_response('announce/write_message.html', {
            'form': form,
            'user': request.user,
        })
    # Valid message: send it!
    s = ''
    for user in get_active_members():
        ci = ContactInfo.objects.get(user=user)
        try:
            send_mail(form.cleaned_data['subject'],
                      form.cleaned_data['body'],
                      settings.HOS_ANNOUNCE_FROM, [user.email],
                      fail_silently=False)
            ci.last_email_ok = True
            ci.save()
        except smtplib.SMTPException, instance:
            f = open('/announcelog.log', 'a')
            f.write('\n\n' + user.email)
            f.write('\n' + repr(instance))
            ci.last_email_ok = False
            ci.save()
            f.close()
Beispiel #4
0
def announce(request):
    print 'wtf:' + repr(request.user)
    form = AnnouncementForm(request.POST or None)
    if not request.POST or not form.is_valid():
        return render_to_response('announce/write_message.html',
                                  {
                                   'form': form,
                                   'user': request.user,
                                  })
    # Valid message: send it!
    s = ''
    for user in get_active_members():
        ci = ContactInfo.objects.get(user=user)
        try:
            send_mail(form.cleaned_data['subject'],
                      form.cleaned_data['body'],
                      settings.HOS_ANNOUNCE_FROM,
                      [user.email],
                      fail_silently=False)
            ci.last_email_ok = True
            ci.save()
        except smtplib.SMTPException, instance:
            f = open('/announcelog.log', 'a')
            f.write('\n\n'+user.email)
            f.write('\n'+repr(instance))
            ci.last_email_ok = False
            ci.save()
            f.close()
Beispiel #5
0
def announce(request):
    print 'wtf:' + repr(request.user)
    form = AnnouncementForm(request.POST or None)
    if not request.POST or not form.is_valid():
        return render_to_response('announce/write_message.html',
                                  {
                                   'form': form,
                                   'user': request.user,
                                  })
    # Valid message: send it!
    s = ''

    users = get_active_members()
    if form.cleaned_data['to']!='all':
        users = users.filter(paymentinfo__bank_collection_allowed=True)\
                     .filter(paymentinfo__bank_collection_mode__id=4)
        for u in users:
            debt = u.contactinfo_set.all()[0].get_debt_for_month(date.today())
            if debt == 0:
                users = users.exclude(pk=u.pk)

    for user in users:
        ci = ContactInfo.objects.get(user=user)
        try:
            send_mail(form.cleaned_data['subject'],
                      form.cleaned_data['body'],
                      settings.HOS_ANNOUNCE_FROM,
                      [user.email],
                      fail_silently=False)
            ci.last_email_ok = True
            ci.save()
        except smtplib.SMTPException, instance:
            f = open(settings.HOS_ANNOUNCE_LOG, 'a')
            f.write('\n\n'+user.email)
            f.write('\n'+repr(instance))
            ci.last_email_ok = False
            ci.save()
            f.close()
Beispiel #6
0
Datei: views.py Projekt: jaeh/mos
def announce(request):
    print 'wtf:' + repr(request.user)
    form = AnnouncementForm(request.POST or None)
    if not request.POST or not form.is_valid():
        return render_to_response('announce/write_message.html',
                                  {
                                   'form': form,
                                   'user': request.user,
                                  })
    # Valid message: send it!
    s = ''

    users = get_active_members()
    if form.cleaned_data['to']!='all':
        users = users.filter(paymentinfo__bank_collection_allowed=True)\
                     .filter(paymentinfo__bank_collection_mode__id=4)
        for u in users:
            debt = u.contactinfo_set.all()[0].get_debt_for_month(date.today())
            if debt == 0:
                users = users.exclude(pk=u.pk)

    for user in users:
        ci = ContactInfo.objects.get(user=user)
        try:
            send_mail(form.cleaned_data['subject'],
                      form.cleaned_data['body'],
                      settings.HOS_ANNOUNCE_FROM,
                      [user.email],
                      fail_silently=False)
            ci.last_email_ok = True
            ci.save()
        except smtplib.SMTPException, instance:
            f = open(settings.HOS_ANNOUNCE_LOG, 'a')
            f.write('\n\n'+user.email)
            f.write('\n'+repr(instance))
            ci.last_email_ok = False
            ci.save()
            f.close()
Beispiel #7
0
import os
import sys

from mos.members.models import get_active_members

os.environ['DJANGO_SETTINGS_MODULE'] = "mos.settings"
sys.path.append("/django/deployment")

for user in get_active_members():
    user.is_active = True
    user.save()

    print user, user.email
Beispiel #8
0
import os
import sys

from mos.members.models import get_active_members


os.environ['DJANGO_SETTINGS_MODULE'] = "mos.settings"
sys.path.append("/django/deployment")


for user in get_active_members():
    user.is_active = True
    user.save()

    print user, user.email