Esempio n. 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]))
Esempio n. 2
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()
Esempio n. 3
0
import os
import sys

from hos.members.models import get_active_members


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


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

    print user, user.email