def license(request, id=None): @logged_in_or_basicauth() def handle_update(request, license): data = simplejson.loads(request.raw_post_data) warnings = [] if not license.id: if 'url' in data: ls = License.objects.filter(url=data['url']) if ls.count(): license = ls[0] warnings.append( "URL of license matched existing license %s; updating that license instead of creating a new license." % ls[0].id) license.from_json(data) license.save() return json_response(request, license, warnings=warnings) if id == None and request.method == "POST": l = License() return handle_update(request, l) elif id != None: l = License.objects.get(pk=id) if request.method == "DELETE": l.delete() return json_response(request, "") if request.method == "POST": return handle_update(request, l) return json_response(request, l) else: licenses = License.objects.all() data = {'licenses': [l.to_json() for l in licenses]} return json_response(request, data)
def startfreelicense(data): city = City.objects.get(pk=data['city']) organization = Organization.objects.get(pk=data['id']) subscription = Subscription.objects.get(name__iexact='starter-premium') pathway = PaymentPathway.objects.get(name__iexact='free') status = LicenseStatus.objects.get(name__iexact='active') frenshiseset = Frenchise(name=data['name'], ismain=True, email=data['email'], phone=data['phone'], address=data['address'], city=city, organization=organization).save() licenseset = License(organization=organization, licensestatus=status).save() registrationset = Registration( subscription=subscription, organization=organization, pathway=pathway, ends=datetime(2020, 3, 31), ).save()
def issue_license(application): _license = License( serial=application.serial, status=LicenseStatus.objects.get(value=LicenseStatus.VALID), application=application, action_date=datetime.today(), duration=Application.NEW_YEARS) _license.save() if _license.id: return True else: return False
def license(request, id=None): if id == None and request.method == "POST": data = simplejson.loads(request.raw_post_data) l = License() l.from_json(data) return json_response(request, l) elif id != None: l = License.objects.get(pk=id) if request.method == "POST": data = simplejson.loads(request.raw_post_data) l.from_json(data) l.save() return json_response(request, l) else: licenses = License.objects.all() data = {'licenses': [l.to_json() for l in licenses]} return json_response(request, data)