Exemplo n.º 1
0
    def handle(self, *args, **options):
        try:
            with NamedTemporaryFile(suffix=".pdf", prefix='sikteeri', delete=False) as target_file:

                pdfcontent = BillingCycle.get_pdf_reminders(memberid=options['member'])
                target_file.write(pdfcontent)
                target_file.close()
                pdffile = target_file.name

            if pdffile:
                print("pdf file created: %s" % pdffile)
            else:
                print("Cannot create pdffile")
        except RuntimeError as e:
            raise CommandError(e)
Exemplo n.º 2
0
     membership.views.billing_object_list, {
         'queryset':
         BillingCycle.objects.filter(is_paid__exact=False,
                                     membership__status='A').order_by(
                                         'start', 'id'),
         'template_name':
         'membership/bill_list.html',
         'context_object_name':
         'cycle_list',
         'paginate_by':
         ENTRIES_PER_PAGE
     },
     name='unpaid_cycle_list'),
 url(r'bills/locked/$',
     membership.views.billing_object_list, {
         'queryset': BillingCycle.get_reminder_billingcycles(),
         'template_name': 'membership/bill_list.html',
         'context_object_name': 'cycle_list',
         'paginate_by': ENTRIES_PER_PAGE
     },
     name='locked_cycle_list'),
 url(r'bills/print_reminders/$',
     membership.views.print_reminders,
     name='print_reminders'),
 url(r'payments/$',
     membership.views.billing_object_list, {
         'queryset': payments,
         'template_name': 'membership/payment_list.html',
         'context_object_name': 'payment_list',
         'paginate_by': ENTRIES_PER_PAGE
     },
Exemplo n.º 3
0
         name='membership_search'),

    url(r'bills/$', 'membership.views.billing_object_list',
        {'queryset': BillingCycle.objects.filter(
            membership__status='A').order_by('-start', '-id'),
         'template_name': 'membership/bill_list.html',
         'context_object_name': 'cycle_list',
         'paginate_by': ENTRIES_PER_PAGE}, name='cycle_list'),
    url(r'bills/unpaid/$', 'membership.views.billing_object_list',
        {'queryset': BillingCycle.objects.filter(is_paid__exact=False,
            membership__status='A').order_by('start', 'id'),
         'template_name': 'membership/bill_list.html',
         'context_object_name': 'cycle_list',
         'paginate_by': ENTRIES_PER_PAGE}, name='unpaid_cycle_list'),
    url(r'bills/locked/$', 'membership.views.billing_object_list',
        {'queryset': BillingCycle.get_reminder_billingcycles(),
         'template_name': 'membership/bill_list.html',
         'context_object_name': 'cycle_list',
         'paginate_by': ENTRIES_PER_PAGE}, name='locked_cycle_list'),
    url(r'bills/print_reminders/$', 'membership.views.print_reminders',
            name='print_reminders'),

    url(r'payments/$', 'membership.views.billing_object_list',
        {'queryset': payments,
         'template_name': 'membership/payment_list.html',
         'context_object_name': 'payment_list',
         'paginate_by': ENTRIES_PER_PAGE}, name='payment_list'),
    url(r'payments/unknown/$', 'membership.views.billing_object_list',
        {'queryset': payments.filter(billingcycle=None, ignore=False),
         'template_name': 'membership/payment_list.html',
         'context_object_name': 'payment_list',
Exemplo n.º 4
0
def create_member(mdata, logins):
    # legacy fields
    # ['application_id', 'sendinfo', 'memberclass', 'applicationtime', 'sms',
    # 'id', 'email', 'website', 'publicwebsite', 'lastname', 'phone',
    # 'firstnames', 'address', 'nationality', 'post', 'removed', 'publicname',
    # 'name', 'mobile', 'residence', 'time', 'publicemail', 'period_start',
    # 'period_end']
    # TODO: latest billing period start date?
    post_index = mdata['post'].find(' ')
    postcode = mdata['post'][:post_index]
    postoffice = mdata['post'][post_index+1:]
    d = {
        'street_address' : mdata['address'],
        'postal_code' : postcode,
        'post_office' : postoffice,
        'country' : mdata['nationality'],
        'phone' : mdata['phone'].replace(" ", "").replace("-", ""),
        'sms' : mdata['sms'].replace(" ", "").replace("-", ""),
        'email' : mdata['email'].strip(" "),
        'homepage' : mdata['website'].strip(" "),
        'first_name' : mdata['name'].strip(" "),
        'given_names' : mdata['firstnames'].strip(" "),
        'last_name' : mdata['lastname'].strip(" "),
        # mdata['application_id'],
        # mdata['sendinfo'],
    }

    # Hide non-public websites
    if not mdata['publicwebsite']:
        d['homepage'] = ""

    if not mdata['memberclass']:
        mtype = 'P'
        print >> sys.stderr, "# Member type missing for member %d" % mdata['id']
    elif mdata['memberclass'] == 'member':
        mtype = 'P'
    elif mdata['memberclass'] == 'supporting':
        mtype = 'S'
    elif mdata['memberclass'] == 'organization':
        mtype = 'O'
    elif mdata['memberclass'] == 'honorary':
        mtype = 'H'
    else:
        print >> sys.stderr, "! Not importing, member class unknown for member %d" % mdata['id']
        return False

    contact = Contact(**d)
    contact.save()
    if mtype == 'O':
        membership = Membership(id=mdata['id'], type=mtype, status='A',
                                created=datetime.utcfromtimestamp(mdata['time']),
                                approved=datetime.utcfromtimestamp(mdata['time']),
                                organization=contact,
                                nationality=mdata['nationality'],
                                municipality=mdata['residence'],
                                extra_info='Imported from legacy',
                                public_memberlist=bool(mdata['publicname']))
    else:
        membership = Membership(id=mdata['id'], type=mtype, status='A',
                                created=datetime.utcfromtimestamp(mdata['time']),
                                approved=datetime.utcfromtimestamp(mdata['time']),
                                person=contact,
                                nationality=mdata['nationality'],
                                municipality=mdata['residence'],
                                extra_info='Imported from legacy',
                                public_memberlist=bool(mdata['publicname']))
    logger.info("Member %s imported from legacy database." % (unicode(contact)))
    membership.save()

    # Create a period only if there already is one previously. Else let
    # makebills create one.
    if mdata.has_key('period_start'):
        billing_cycle = BillingCycle(membership=membership, is_paid=False,
                                     start=datetime.strptime(mdata['period_start'], "%Y-%m-%d %H:%M:%S"),
                                     end=datetime.strptime(mdata['period_end'], "%Y-%m-%d %H:%M:%S")+timedelta(days=1))
        billing_cycle.save()
        bill = Bill(billingcycle=billing_cycle)
        bill.save()
        # Due to auto_now_add, need to save first before changing
        bill.created=datetime.strptime(mdata['bill_creation'], "%Y-%m-%d %H:%M:%S")
        bill.due_date=datetime.strptime(mdata['bill_dueday'], "%Y-%m-%d %H:%M:%S")
        bill.save()
    for alias in mdata['aliases']:
        if alias in logins:
            a = Alias(owner=membership, name=alias, account=True,
                      created=membership.created)
        else:
            a = Alias(owner=membership, name=alias, account=False,
                      created=membership.created)
        a.save()

        account_alias_count = Alias.objects.filter(owner=a.owner, account=True).count()
        if account_alias_count > 1:
            logger.warning("%i account aliases for %s" % (account_alias_count, a.owner))

    log_change(membership, user, change_message="Imported into system")
    return True