Exemplo n.º 1
0
def index(request):
    fossils_query = Fossil.all().order('-date')
    fossils = fossils_query.fetch(10)

    login_linktext, login = user_stuff(request)

    template_values = {
      'fossils': fossils,
      'login': login,
      'login_linktext': login_linktext,
      }
    return render_to_response('index.html',template_values)
Exemplo n.º 2
0
def show(request,slug):
    
    fossils_query = Fossil.all().filter('slug =', slug)
    fossils = fossils_query.fetch(1)
    
    login_linktext, login = user_stuff(request)
        
    template_values = {
        'fossils': fossils,
        'login': login,
        'login_linktext': login_linktext,
        }
    
    return render_to_response("fossil.html",template_values)
Exemplo n.º 3
0
def new(request):
    if request.method == 'POST':
        form = FossilForm(request.POST, request.FILES)
        if form.is_valid():
            logging.log(logging.DEBUG, form.cleaned_data)
            f= Fossil()
            f.author = request.user
            f.title = form.cleaned_data['title']
            f.slug = form.cleaned_data['slug']
            f.species = form.cleaned_data['species']
            f.antiquity = form.cleaned_data['antiquity']
            f.doi = form.cleaned_data['doi']
            f.loc = db.GeoPt(lat=form.cleaned_data['lat'],lon=form.cleaned_data['long'])
            f.field_site = form.cleaned_data['field_site']
            i = images.Image(form.cleaned_data['image'].content)
            f.image = i.execute_transforms()
            f.populate_doi(f.doi)
            # Do form processing here...
            return HttpResponseRedirect('/')
    else:
        form = FossilForm()

    return render_to_response('new.html', {'form': form})