def new_organization(request): org = Organization.raw_objects.create(account=request.account) try: transaction.commit() except: pass save_action.delay(request.account, request.useraccount, "created an organization", organization=org) return HttpResponseRedirect("%s?edit=ON" %reverse("organizations:organization",args=(org.pk,)))
def wrapper(request, *args, **kwargs): ret = function(request, *args, **kwargs) try: transaction.commit() except: pass save_action.delay(account, action_type, **action_kwargs) return ret
def save_person_basic_info(request, person_id): person = get_or_404_by_account(Person, request.account, person_id) (form, employee_formset) = _basic_forms(person, request) success = False if form.is_valid() and employee_formset.is_valid(): person = form.save() employee_formset.save() success = True save_action.delay(request.account, request.useraccount, "updated a person", person=person,) return {"success":success}
def save_basic_info(request, spreadsheet_id): spreadsheet = get_or_404_by_account(Spreadsheet, request.account, spreadsheet_id, using='default') form = _basic_forms(spreadsheet, request) success = False if form.is_valid(): spreadsheet = form.save() success = True save_action.delay(request.account, request.useraccount, "updated a spreadsheet", spreadsheet=spreadsheet,) # form = _basic_forms(spreadsheet, request, no_data=True) return {"success":success}
def save_organization_basic_info(request, org_id): org = get_or_404_by_account(Organization, request.account, org_id, using='default') (form, form_new_person, form_employee, employee_formset) = _org_forms(org, request) success = False if form.is_valid(): form.save() try: transaction.commit() except: pass save_action.delay(request.account, request.useraccount, "updated an organization", organization=org) success = True return {"success":success}
def save_completed_volunteer_shift(request, volunteer_id): volunteer = get_or_404_by_account(Volunteer, request.account, volunteer_id, using='default') person = volunteer.person if request.method == "POST": form = NewShiftForm(request.POST, account=request.account) if form.is_valid(): completed_shift = form.save(commit=False) completed_shift.volunteer = volunteer completed_shift.save() try: transaction.commit() except: pass save_action.delay(request.account, request.useraccount, "added a volunteer shift", person=person, shift=completed_shift) obj = volunteer return _return_fragments_or_redirect(request,locals())
def queue_generation(request): success = True file_type = request.GET['type'] spreadsheet_id = request.GET['spreadsheet_id'] spreadsheet = get_or_404_by_account(Spreadsheet, request.account, spreadsheet_id) downloaded_spreadsheet = DownloadedSpreadsheet.objects.create( account=request.account, name=spreadsheet.full_name, num_records = spreadsheet.num_rows, file_type = spreadsheet.default_filetype, spreadsheet=spreadsheet, ) generate_spreadsheet.delay(request.account.id, request.useraccount.id, spreadsheet.id, downloaded_spreadsheet.id, file_type) save_action.delay(request.account, request.useraccount, "generated a spreadsheet", spreadsheet=spreadsheet,) return {"success": success}
def save_new_donation(request, donor_id): donor = get_or_404_by_account(Donor, request.account, donor_id, using='default') person = donor.person obj = donor if request.method == "POST": form = NewDonationForm(request.POST, account=request.account) if form.is_valid(): new_donation = form.save(commit=False) new_donation.donor = donor new_donation.save() try: transaction.commit() except: pass save_action.delay(request.account, request.useraccount, "added a donation", person=person, donation=new_donation) else: print form return _return_fragments_or_redirect(request,locals())
def save_new_conversation(request, person_id): person = get_or_404_by_account(Person, request.account, person_id, using="default") obj = person if request.method == "POST": form = NewConversationForm(request.POST, account=request.account) if form.is_valid(): new_conversation = form.save(commit=False) new_conversation.person = person new_conversation.save() try: transaction.commit() except: pass save_action.delay( request.account, request.useraccount, "added a conversation", person=person, conversation=new_conversation, ) else: print form return _return_fragments_or_redirect(request, locals())
def new_person(request): person = Person.raw_objects.create(account=request.account) save_action.delay(request.account, request.useraccount, "created a person", person=person,) return HttpResponseRedirect("%s?edit=ON" %reverse("people:person",args=(person.pk,)))
def new(request): spreadsheet = Spreadsheet.raw_objects.using('default').create(account=request.account) save_action.delay(request.account, request.useraccount, "created a spreadsheet", spreadsheet=spreadsheet,) return HttpResponseRedirect("%s?edit=ON" %reverse("spreadsheets:spreadsheet",args=(spreadsheet.pk,)))