Ejemplo n.º 1
0
def download(request):
    user = auth.get_current_user(request)    
    if not user:
        pin = request.GET["pin"].upper()
        code = request.GET["code"]
        product = Product.get_by_key_name("ContactLoader")
        userproduct = UserProduct.gql("where product = :1 and pin = :2", 
                                      product, pin).get()
        if not userproduct or not userproduct.validate_code(code):
            raise Http404("Could not find activation data")
        user = userproduct.parent()
    lst = ImportList.gql("where user = :1", user).get()
    if not lst:
        raise Http404("No list has been uploaded on the account yet")
    return HttpResponse(lst.data, "text/csv")
Ejemplo n.º 2
0
def index(request):
    user = auth.get_current_user(request)
    product = Product.get_by_key_name("ContactLoader")
    lst = None
    form = None
    reg = UserProduct.get_product(user, product)
    if reg:            
        if request.method == "POST":
            form = handle_upload(request)
        else:
            form = UploadForm()
        lst = ImportList.gql("where user = :1", user).get()
    return render_to_response('contactloader/index.html', 
                              {'lst': lst, 
                               'reg': reg, 
                               'product': product,
                               'form': form },
                              RequestContext(request))