コード例 #1
0
ファイル: deactivate_users.py プロジェクト: redtidenyc/site
def main():
    usage = 'usage: %prog [ options ] arg'
    parser = OptionParser()
    parser.add_option(
        '-f',
        '--fakeit',
        dest='fakeit',
        action='store_true',
        help=
        'This causes a list of the users who would be deactivated to be printed to the terminal'
    )
    (options, args) = parser.parse_args()
    annual_plan = get_annual_plan()
    coaches_plan = get_current_coaches_plan()
    """ Get the set of swimmers who have no corresponding registration object attached to a current annual plan thats paid """
    for s in Swimmer.objects.filter(user__is_active=True):
        try:
            r = Registration.objects.get(
                swimmer__id__exact=s.id,
                plan__id__in=[annual_plan.id, coaches_plan.id],
                registration_status__exact=PAID)
        except Registration.DoesNotExist:
            print >> sys.stderr, 'Deactivating %s' % s
            if not options.fakeit:
                s.user.is_active = False
                s.user.save()
コード例 #2
0
ファイル: enroll_in_list.py プロジェクト: redtidenyc/site
def main():

	usage = 'usage: %prog [options] arg'
	parser = OptionParser()
	parser.add_option('-p', '--package', dest='package', help='The name or package id used as condition of enrollment')
	parser.add_option('-l', '--list', dest='list', help='The list email address to enroll everyone in')
	parser.add_option('-c', '--clearlist', action='store_true', dest='clear', help='Clear out the mailing list.')
	parser.add_option('-i', '--inactive', action='store_true', dest='inactive', help='Only add inactive users')
	(options, args) = parser.parse_args()
	if not options.list:
		parser.error('a list need to be defined')
	
	try:
		mlist = MailingList.objects.get(listaddress__exact=options.list)
	except MailingList.ListDoesNotExist:
		parser.error('invalid list passed through')
	
	if options.clear:
		print >> sys.stderr, 'Clearing list %s' % options.list
		mlist.swimmers.clear()
		mlist.save()
		return

	plan = None
	if options.package:
		if re.match('^\d+$', options.package):
			package_id = int(options.package)
			try:
				plan = Plan.objects.get(pk=package_id)
			except Plan.DoesNotExist:
				parser.error('plan id %d does not exist' % package_id )
		else:
			package_name = options.package
			try:
				plan = Plan.objects.get(name__icontains=package_name)
			except plans.PlanDoesNotExist:
				parser.error('plan id %d does not exist' % package_id )
			
	else:
		 plan = get_annual_plan()
	if not plan:
		print >>sys.stderr, 'There is something really wrong, can\'t find any valid plans'
		os.exit(1)
	registrants = []
	if not options.inactive:
		registrants = Registration.objects.filter(plan__id__exact=plan.id, registration_status__exact=PAID)
	else:
		registrants = Registration.objects.filter(swimmer__user__is_active=False, plan__id__exact=plan.id, registration_status__exact=PAID)
		
	mlist.swimmers = [ r.swimmer for r in registrants ]
	mlist.save()
	return
コード例 #3
0
ファイル: deactivate_users.py プロジェクト: redtidenyc/site
def main():
    usage = 'usage: %prog [ options ] arg'
    parser = OptionParser()
    parser.add_option('-f', '--fakeit', dest='fakeit', action='store_true',
        help='This causes a list of the users who would be deactivated to be printed to the terminal')
    (options, args) = parser.parse_args()
    annual_plan = get_annual_plan()
    coaches_plan = get_current_coaches_plan()
    """ Get the set of swimmers who have no corresponding registration object attached to a current annual plan thats paid """
    for s in Swimmer.objects.filter(user__is_active=True):
        try:
            r = Registration.objects.get(swimmer__id__exact=s.id, plan__id__in=[ annual_plan.id, coaches_plan.id ],
                registration_status__exact=PAID)
        except Registration.DoesNotExist:
            print >> sys.stderr, 'Deactivating %s' % s
            if not options.fakeit:
                s.user.is_active = False
                s.user.save()
コード例 #4
0
ファイル: enroll_in_list.py プロジェクト: redtidenyc/site
def main():

    usage = 'usage: %prog [options] arg'
    parser = OptionParser()
    parser.add_option(
        '-p',
        '--package',
        dest='package',
        help='The name or package id used as condition of enrollment')
    parser.add_option('-l',
                      '--list',
                      dest='list',
                      help='The list email address to enroll everyone in')
    parser.add_option('-c',
                      '--clearlist',
                      action='store_true',
                      dest='clear',
                      help='Clear out the mailing list.')
    parser.add_option('-i',
                      '--inactive',
                      action='store_true',
                      dest='inactive',
                      help='Only add inactive users')
    (options, args) = parser.parse_args()
    if not options.list:
        parser.error('a list need to be defined')

    try:
        mlist = MailingList.objects.get(listaddress__exact=options.list)
    except MailingList.ListDoesNotExist:
        parser.error('invalid list passed through')

    if options.clear:
        print >> sys.stderr, 'Clearing list %s' % options.list
        mlist.swimmers.clear()
        mlist.save()
        return

    plan = None
    if options.package:
        if re.match('^\d+$', options.package):
            package_id = int(options.package)
            try:
                plan = Plan.objects.get(pk=package_id)
            except Plan.DoesNotExist:
                parser.error('plan id %d does not exist' % package_id)
        else:
            package_name = options.package
            try:
                plan = Plan.objects.get(name__icontains=package_name)
            except plans.PlanDoesNotExist:
                parser.error('plan id %d does not exist' % package_id)

    else:
        plan = get_annual_plan()
    if not plan:
        print >> sys.stderr, 'There is something really wrong, can\'t find any valid plans'
        os.exit(1)
    registrants = []
    if not options.inactive:
        registrants = Registration.objects.filter(
            plan__id__exact=plan.id, registration_status__exact=PAID)
    else:
        registrants = Registration.objects.filter(
            swimmer__user__is_active=False,
            plan__id__exact=plan.id,
            registration_status__exact=PAID)

    mlist.swimmers = [r.swimmer for r in registrants]
    mlist.save()
    return
コード例 #5
0
ファイル: registration.py プロジェクト: redtidenyc/site
    def calcowed(self, plan, sid):
        ret_val = {'plans': [], 'owed': 0.0}
        plan_ids = []
        owed = 0.0
        annual_plan = get_annual_plan()
        pid, sid, swimmer, double, owed = int(plan), int(sid), None, True, 0
        annual_paid = False
        plan_paid = False
        if sid > 0:
            """ First check if they've already paid for the annual membership
	    """
            r = Registration.objects.filter(
                swimmer__exact=sid,
                plan__id__exact=annual_plan.id,
                registration_status__in=[PAID, PENDING],
                plan__reg_period__period_start__lte=datetime.now(),
                plan__reg_period__period_end__gte=datetime.now())
            if len(r) > 0:
                annual_paid = True
                """ If we were only trying to register annual, return now.
		"""
                if pid == annual_plan.id:
                    plan_ids.append(pid)
                    owed = 0.0
                    ret_val['owed'] = '%0.2lf' % owed
                    ret_val['plans'] = plan_ids
                    return ret_val
            """ If they are trying to buy a recurring package they've 
	        already paid for we deal with that
	    """
            r = Registration.objects.filter(
                swimmer__exact=sid,
                plan__id__exact=pid,
                registration_status__exact=PAID,
                plan__isrecurring__exact=True,
                plan__reg_period__period_start__lte=datetime.now(),
                plan__reg_period__period_end__gte=datetime.now())
            if len(r) > 0:
                plan_paid = True
                """
	        If we've already paid for annual return now
		"""
                if annual_paid:
                    owed += 0.0
                    plan_ids.append(pid)
                    ret_val['plans'] = plan_ids
                    ret_val['owed'] = '%0.2lf' % owed
                    return ret_val
        """
            After this point we are looking at a new swimmer
        """
        pidPlan = Plan.objects.get(pk=pid)
        if not plan_paid:
            owed += pidPlan.base_amount

        if pidPlan.add_annual and (not annual_paid):
            plan_ids.append(annual_plan.id)
            owed += int(annual_plan.base_amount)

        plan_ids.append(pid)
        ret_val['plans'] = plan_ids
        ret_val['owed'] = '%0.2lf' % owed
        ret_val['annual'] = annual_plan.id

        return ret_val
コード例 #6
0
ファイル: registration.py プロジェクト: redtidenyc/site
    def calcowed(self, plan, sid):
	ret_val = { 'plans':[], 'owed':0.0 }
	plan_ids = []
	owed = 0.0
	annual_plan = get_annual_plan()
	pid, sid, swimmer, double, owed = int(plan), int(sid), None, True, 0
	annual_paid = False
	plan_paid = False
	if sid > 0:
	    """ First check if they've already paid for the annual membership
	    """		
	    r = Registration.objects.filter(swimmer__exact=sid,
		    plan__id__exact=annual_plan.id,
		    registration_status__in=[PAID,PENDING],
		    plan__reg_period__period_start__lte=datetime.now(),
		    plan__reg_period__period_end__gte=datetime.now())
	    if len(r) > 0:
	        annual_paid = True

	        """ If we were only trying to register annual, return now.
		"""
		if pid == annual_plan.id:
		    plan_ids.append(pid)
		    owed = 0.0
		    ret_val['owed'] = '%0.2lf' % owed
		    ret_val['plans'] = plan_ids
		    return ret_val

	    """ If they are trying to buy a recurring package they've 
	        already paid for we deal with that
	    """
	    r = Registration.objects.filter(swimmer__exact=sid, 
	            plan__id__exact=pid,
		    registration_status__exact=PAID,
		    plan__isrecurring__exact=True,
		    plan__reg_period__period_start__lte=datetime.now(), 
		    plan__reg_period__period_end__gte=datetime.now())
	    if len(r) > 0:
	        plan_paid = True	

	        """
	        If we've already paid for annual return now
		"""
		if annual_paid:
		    owed += 0.0
		    plan_ids.append(pid) 
		    ret_val['plans'] = plan_ids
		    ret_val['owed'] = '%0.2lf' % owed 
		    return ret_val
	
        """
            After this point we are looking at a new swimmer
        """
        pidPlan = Plan.objects.get(pk=pid)
	if not plan_paid: 
	    owed += pidPlan.base_amount
			
	if pidPlan.add_annual and ( not annual_paid ):
	    plan_ids.append(annual_plan.id)
	    owed += int(annual_plan.base_amount)

	
        plan_ids.append(pid)	
        ret_val['plans'] = plan_ids
	ret_val['owed'] = '%0.2lf' % owed	
	ret_val['annual'] = annual_plan.id

	return ret_val