Exemplo n.º 1
0
    def handle(self, *args, **options):
        if len(args):
            self.stdout.write('refreshevents takes no arguments \n')
            return

        # Gather new collegiatelink events
        EventController().fetch_collegiatelink_events();
        self.stdout.write('gathered collegiatelink events \n')

        # Gather new Facebook events from watched pages
        facebook_event_pages = FacebookEventPageController().facebook_event_pages()
        for event_page in facebook_event_pages:
            FacebookEventPageController().scrape_page_events(event_page)
        self.stdout.write('gathered Facebook page events \n')
Exemplo n.º 2
0
def home (request):
	if request.method == 'GET': # Render the events index on GET
		events = EventController.approved_events()
		weeks_events = EventController.weeks_events()
		return render(request, 'events/home.html', {
			'events': EventHelper.events_to_json(events),
			'earliest_event_time': EventHelper.earliest_event_time(weeks_events),
			'latest_event_time': EventHelper.latest_event_time(weeks_events),
			'facebook_event_pages': FacebookEventPageController.facebook_event_pages()
		})
Exemplo n.º 3
0
def home (request):
	if request.method == 'GET': # Render the events index on GET
		events = EventController.approved_events()
		weeks_events = EventController.weeks_events()
		return render(request, 'events/home.html', {
			'events': EventHelper.events_to_json(events),
			'earliest_event_time': EventHelper.earliest_event_time(weeks_events),
			'latest_event_time': EventHelper.latest_event_time(weeks_events),
			'facebook_event_pages': FacebookEventPageController.facebook_event_pages()
		})
	else:
		return HttpResponseNotAllowed(['GET'])
Exemplo n.º 4
0
def facebook_page (request):
	if request.method == 'POST':
		try:
			new_event_page = FacebookEventPageController.new_facebook_event_page(dict(urlparse.parse_qsl(request.body)))
		except InvalidEventException: # Display no error since it's not the submitter's fault that the page has malformed events
			pass
		except InvalidFacebookEventPageException as e:
			return HttpResponse(
				content=e.error_message,
				status=500
			)
		return HttpResponse(serializers.serialize('json', [new_event_page])) # Return a JSON hash of the new event page
Exemplo n.º 5
0
def facebook_page (request):
	if request.method == 'POST':
		try:
			new_event_page = FacebookEventPageController.new_facebook_event_page(dict(urlparse.parse_qsl(request.body)))
		except InvalidEventException: # Display no error since it's not the submitter's fault that the page has malformed events
			pass
		except InvalidFacebookEventPageException as e:
			return HttpResponse(
				content=e.error_message,
				status=500
			)
		return HttpResponse(serializers.serialize('json', [new_event_page])) # Return a JSON hash of the new event page
	else:
		return HttpResponseNotAllowed(['POST'])