def excel_group(request, group_id, name): group = Group.get_by_id(group_id) wb = xlwt.Workbook() if group: write_category(wb, group) out = StringIO.StringIO() wb.save(out) headers = Headers() headers['Content-Type'] = 'application/ms-excel' headers['Content-Transfer-Encoding'] = 'Binary' headers['Content-disposition'] = 'attachment; filename="%s"' % name response = Response(out.getvalue(), headers=headers) return response
def group_edit(request, id): group = Group.get_by_id(id) if not group: return redirect('category/admin/groups') form = GroupForm(instance=group) if request.method == 'POST': if form.validate(request.form): tmp = form.save(commit=False) if group.category != tmp.category: for gift in group.gifts: gift.category = tmp.category gift.push() group = tmp group.put() return redirect('category/admin/groups') return render_to_response('category/admin/groups.html', {'form':form.as_widget(), 'groups':Group.all().order('category').order('name'), 'edit_flag':True})
def group_delete(request, id): group = Group.get_by_id(id) if group: group.delete() return redirect('category/admin/groups')
def get_group_mem(group): return Group.get_by_id(group)