Exemple #1
0
def make_json(request, start=None):
    if not start:
        start = utc.localize(datetime.utcnow()).astimezone(
            request.site.tz).date()
    continuing = Event.all().filter('status = ', 'approved').filter(
        'multiday =', True).filter('continues =', str(start))
    events_soon = Event.all().filter('status = ',
                                     'approved').order('local_start').filter(
                                         'local_start >= ', start)

    flattened_events = []
    for event in chain(continuing, events_soon):
        flattened_events.append({
            'title': event.title,
            'start': event.start.isoformat(),
            'end': event.end.isoformat(),
            'location': event.location,
            'link': event.link,
            'cost': event.cost,
            'credit_name': event.credit_name,
            'credit_link': event.credit_link,
        })

    response = HttpResponse(json.dumps(flattened_events),
                            mimetype='application/json')
    response['Cache-Control'] = "public; max-age=3600;"
    return response
Exemple #2
0
def this_week_rss(request):

    parsed_day=request.site.today
    start=parsed_day+relativedelta(weekday=MO(-1))
    begin_next_week=start+relativedelta(days=1, weekday=MO(+1))
    end=start+relativedelta(weekday=SU)
    continuing=Event.all().filter('status = ', 'approved').filter('continues =', str(start)).filter('local_start < ', start).fetch(150)
    events_soon=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).filter('local_start < ', begin_next_week).fetch(150)
    

    template='eventsite/week.xml'

    response= render_to_response(template, locals(), context_instance=RequestContext(request),mimetype='application/rss+xml')
    response['Cache-Control']="public; max-age=3600;"
    return response   
Exemple #3
0
def this_week_rss(request):

    parsed_day=request.site.today
    start=parsed_day+relativedelta(weekday=MO(-1))
    begin_next_week=start+relativedelta(days=1, weekday=MO(+1))
    end=start+relativedelta(weekday=SU)
    continuing=Event.all().filter('status = ', 'approved').filter('continues =', str(start)).filter('local_start < ', start).fetch(150)
    events_soon=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).filter('local_start < ', begin_next_week).fetch(150)


    template='eventsite/week.xml'

    response= render_to_response(template, locals(), context_instance=RequestContext(request),mimetype='application/rss+xml')
    response['Cache-Control']="public; max-age=3600;"
    return response
Exemple #4
0
def week_of_index(request, datestring=None, format=None):

    parsed_day=parse(datestring).date()
    start=parsed_day+relativedelta(weekday=MO(-1))
    begin_next_week=start+relativedelta(days=1, weekday=MO(+1))
    end=start+relativedelta(weekday=SU)
    continuing=Event.all().filter('status = ', 'approved').filter('continues =', str(start)).filter('local_start < ', start).fetch(150)
    events_soon=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).filter('local_start < ', begin_next_week).fetch(150)

    if format == 'newsletter':
        template='eventsite/newsletter.html'
    else:
        template='eventsite/week.html'

    return render_to_response(template, locals(), context_instance=RequestContext(request))
Exemple #5
0
def week_of_index(request, datestring=None, format=None):

    parsed_day=parse(datestring).date()
    start=parsed_day+relativedelta(weekday=MO(-1))
    begin_next_week=start+relativedelta(days=1, weekday=MO(+1))
    end=start+relativedelta(weekday=SU)
    continuing=Event.all().filter('status = ', 'approved').filter('continues =', str(start)).filter('local_start < ', start).fetch(150)
    events_soon=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).filter('local_start < ', begin_next_week).fetch(150)
    
    if format == 'newsletter': 
        template='eventsite/newsletter.html'
    else:
        template='eventsite/week.html'

    return render_to_response(template, locals(), context_instance=RequestContext(request))
Exemple #6
0
def ical(request, tag=None):
    if request.site.hostnames:
        host = request.site.hostnames[0]
    else:
        host = request.site.key().id_or_name()
    cal = cal = vobject.iCalendar()
    if tag:
        cal.add('X-WR-CALNAME').value = "%s on %s" % (tag, request.site.name)
    else:
        cal.add('X-WR-CALNAME').value = request.site.name
    start = utc.localize(datetime.utcnow()).astimezone(request.site.tz).date()
    end = start + relativedelta(days=120, weekday=SU(+1))
    continuing = Event.all().filter('status = ', 'approved').filter(
        'multiday =', True).filter('continues =', str(start))
    events_soon = Event.all().filter('status = ',
                                     'approved').order('local_start').filter(
                                         'local_start >= ',
                                         start).filter('local_start < ', end)
    if tag:
        continuing = continuing.filter('tags = ', tag)
        events_soon = events_soon.filter('tags = ', tag)

    for event in chain(continuing, events_soon):
        vevent = cal.add('vevent')
        vevent.add('summary').value = event.title
        vevent.add('dtstart').value = utc.localize(event.start)
        vevent.add('dtend').value = utc.localize(event.end)
        if event.link:
            vevent.add('url').value = event.link

        if event.description:
            vevent.add('description').value = event.description
        elif event.link:
            vevent.add('description').value = "details at: %s" % event.link

        if event.location: vevent.add('location').value = event.location
        vevent.add('uid').value = "%s@%s" % (str(event.key()), host)
    response = HttpResponse(cal.serialize(), mimetype='text/calendar')
    if tag:
        response['Content-Disposition'] = 'attachment; filename=%s_%s.ics' % (
            tag, request.site.slug)
    else:
        response[
            'Content-Disposition'] = 'attachment; filename=%s.ics' % request.site.slug

    response['Cache-Control'] = "public; max-age=3600;"
    return response
Exemple #7
0
def image_view(request, id):
    event = Event.all().filter("eventNumber =",int(id)).get()
    if event and event.image: 
        response = HttpResponse()
        response['Content-Type'] = 'image/png'
        response.write(event.image)
        return response
    else:
        raise Http404('Sorry, I couldnt find that image!')
Exemple #8
0
def front_page(request, tag=None):
    start=request.site.today
    logging.warning("rendering front page of %s starting %s" % (request.site.name, request.site.today+request.site.tz.utcoffset(request.site.tz)))
    upcoming=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).fetch(30)
    
    #upcoming=[event for event in upcoming if 
    response= render_to_response('eventsite/front-page.html', locals(), context_instance=RequestContext(request)) 
    response['Cache-Control']="public; max-age=300;"
    return response
Exemple #9
0
def front_page(request, tag=None):
    start=request.site.today
    logging.warning("rendering front page of %s starting %s" % (request.site.name, request.site.today+request.site.tz.utcoffset(request.site.tz)))
    upcoming=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).fetch(30)
    sponsors=Sponsor.all().filter('active =', True).order('order_rank')

    #upcoming=[event for event in upcoming if
    response= render_to_response('eventsite/front-page.html', locals(), context_instance=RequestContext(request))
    response['Cache-Control']="public; max-age=300;"
    return response
Exemple #10
0
def ical(request, tag=None):
    if request.site.hostnames:
        host= request.site.hostnames[0]
    else:
        host=request.site.key().id_or_name()
    cal = cal = vobject.iCalendar()
    if tag:
        cal.add('X-WR-CALNAME').value="%s on %s"% (tag,request.site.name)
    else:
        cal.add('X-WR-CALNAME').value=request.site.name
    start=utc.localize(datetime.utcnow()).astimezone(request.site.tz).date()
    end=start+relativedelta(days=120, weekday=SU(+1))
    continuing=Event.all().filter('status = ', 'approved').filter('multiday =', True).filter('continues =', str(start))
    events_soon=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start).filter('local_start < ', end)
    if tag:
        continuing=continuing.filter('tags = ', tag)
        events_soon=events_soon.filter('tags = ', tag)
    
    
    for event in chain(continuing,events_soon):
        vevent=cal.add('vevent')
        vevent.add('summary').value=event.title
        vevent.add('dtstart').value=utc.localize(event.start)
        vevent.add('dtend').value=utc.localize(event.end)
        if event.link: 
            vevent.add('url').value=event.link
            
        if event.description: 
            vevent.add('description').value=event.description
        elif event.link:
            vevent.add('description').value="details at: %s" % event.link
            
        if event.location:vevent.add('location').value=event.location
        vevent.add('uid').value="%s@%s" %(str(event.key()), host)
    response= HttpResponse(cal.serialize(), mimetype='text/calendar')
    if tag:
        response['Content-Disposition'] = 'attachment; filename=%s_%s.ics'% (tag,request.site.slug)
    else:
        response['Content-Disposition'] = 'attachment; filename=%s.ics'% request.site.slug
    
    response['Cache-Control']="public; max-age=3600;"
    return response
Exemple #11
0
def make_json(request, start=None):
    if not start:
        start=utc.localize(datetime.utcnow()).astimezone(request.site.tz).date()
    continuing=Event.all().filter('status = ', 'approved').filter('multiday =', True).filter('continues =', str(start))
    events_soon=Event.all().filter('status = ', 'approved').order('local_start').filter('local_start >= ', start)
    
    flattened_events=[]
    for event in chain(continuing,events_soon):
        flattened_events.append({'title': event.title,
                    'start':event.start.isoformat(),
                    'end': event.end.isoformat(),
                    'location':event.location,
                    'link':event.link,
                    'cost':event.cost,
                    'credit_name':event.credit_name,
                    'credit_link':event.credit_link,})
                    
    response= HttpResponse(json.dumps(flattened_events), mimetype='application/json')
    response['Cache-Control']="public; max-age=3600;"
    return response
Exemple #12
0
def main(request):
    events_per_country = generate_events_per_country_list()
    events_count = Event.all().count()
    # TODO: User default country from facebook location
    search_form = SimpleEventFilterForm(initial = {'country': 'GB'})

    r = RequestContext(request, {'events_per_country': events_per_country, 
                                 'events_count' : events_count, 
                                 'search_form' : search_form, 
                                 'mainpage' : True,
                                 'in_iframe' : True,
                                 'FACEBOOK_PROFILE_ID' : settings.FACEBOOK_PROFILE_ID, })

    return render_to_response(request, 'special_events.html', r)
Exemple #13
0
def event_show(request, key_id):
    key_id = int(key_id, 10)
    if request.user.is_authenticated():
        event = get_object_or_404(Event, id=key_id)
        fav = Favourite.all().filter('event =', event).filter('user ='******'invitation'):
        invitation = request.GET['invitation']
    else:
        invitation = 0
    extra_context = { 'is_fav' : fav,
                      'in_iframe' : True,
                      'invitation' : invitation,
                      'invitation_link' : get_facebook_app_url(request.path), }

    return object_detail(request, Event.all(), object_id=key_id, extra_context = extra_context)
Exemple #14
0
    def run(self, url):
        log = ''
        # get data
        if STANDALONE:
            data = backup_or_get_file(url, '/tmp/scrapper.htm')
        else:
            page = urllib2.urlopen(url)
            data = page.read()
        # scrap it
        soup = BeautifulSoup.BeautifulSoup(data)

        results = self._scrap(soup)

        for r in results:
            checksum = self.__getChecksum(r)

            # for every result check if it already exists
            if len(Event.all().filter('checksum =', checksum)) == 0:
                # create event objects if it doesnt
                new_event = self._createEvent(r, checksum, url)
                # if new_Event is None it means results were not enough to create it
                # save to log so that we can email it later
                if new_event:
                    new_event.put()
                    log += 'Created new event %s:\n %s\n' % (new_event.get_absolute_url(), new_event)
                else:
                    log += 'Failed to create event from %s\n'%r

        # email the log now
        if not STANDALONE:
            #import email
            #email.send_email(log)
            pass
        else:
            print log
        return log
Exemple #15
0
 def get(self):
     template_values = engine.globals
     template_values['events'] = Event.all()
     template = engine.jinja_environment.get_template('events/index.html')
     self.response.out.write(template.render(template_values))
Exemple #16
0
def list_latest(request):
    return UA_object_list(request,Event.all().order("time"))
Exemple #17
0
def event_detail(request, id):
    return UA_object_detail(request,Event.all(),slug_field="eventNumber",slug=int(id), template_name="mobile-eventDetail.html", template_object_name = "event")