Esempio n. 1
0
def create_jamah_event(request, jamah_id):
    jamah = Jamah.objects.get(pk=jamah_id)
    name = request.POST['name']
    messages.success(request, 'Added a Event for the jamah...')
    account = Account(description='Event: ' + name + '\'s account')
    account.save()
    cost_account = Account(description='Event: ' + name + '\'s cost account')
    cost_account.save()
    event = Event(name=name,
                  creator=request.user,
                  account=account,
                  jamah=jamah,
                  cost_account=cost_account)
    event.save()
    event.members.add(request.user)
    event.save()
    member_account = Account(description='Event: ' + name + ' ' +
                             ' ,Member: ' + request.user.username)
    member_account.mother_account = event.account
    member_account.save()
    eventMember = EventMember(
        member=request.user,
        event=event,
        status='creator',
        accountant_account=member_account,
        is_accountant=True,
        is_head_accountant=True,
        is_cost_observer=True,
    ).save()
    return HttpResponseRedirect(reverse('jamah:detail', args=(jamah_id, )))
Esempio n. 2
0
def add_accountants(request, event_id):
    event = Event.objects.get(pk=event_id)
    values = request.POST.getlist('member')
    for value in values:
        user = MyUser.objects.get(pk=value)
        eventmember = EventMember.objects.get(member=user, event=event)
        eventmember.is_accountant = True
        account = Account(description='Event: ' + event.name + ' ' +
                          ' ,Accountant: ' + user.username)
        account.mother_account = event.account
        account.save()
        eventmember.accountant_account = account
        eventmember.save()
    event.save()
    messages.success(request, 'Successfully added Accountant !!!')
    return HttpResponseRedirect(reverse('event:detail', args=(event_id, )))