Esempio n. 1
0
def service_run(request, service_id = None):
    if not service_id:
        return generic_error('Invalid service ID')

    try:
        service = UserSocialAuth.objects.get(id = service_id)
    except UserSocialAuth.DoesNotExist:
        return generic_error('Invalid service ID')

    if service.user != request.user:
        return generic_error('That service does not belongs to you')

    # FIXME: Run refresh based on timestamps, not on demand (or not always)

    r = []

    for collector_name in get_collectors_for_auth(service):
        collector = UserCollector.objects.get_or_create(user = service.user,
                                                         auth = service,
                                                         collector = collector_name)[0]
        print "Collector for %s,%s,%s: %s" % (service.user, service,
                                              collector_name, collector)
        r.append(create_collector(collector))

    return HttpResponse(repr(r))
Esempio n. 2
0
def service_delete(request, service_id = None):
    if not service_id:
        return generic_error('Invalid service ID')

    try:
        service = UserSocialAuth.objects.get(id = service_id)
    except UserSocialAuth.DoesNotExist:
        return generic_error('Invalid service ID')

    if service.user != request.user:
        return generic_error('That service does not belongs to you')


    service.delete()
    return redirect('services_list')