def add_to_player_not_li censed request mac if request GET get brand a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def add_to_player_not_licensed(request, mac):
if (
request.GET.get('brand') and
request.GET.get('model') and
request.GET.get('device') and
request.GET.get('brandName')
):
obj, created = Player.objects.get_or_create(mac=mac)
if created:
try:
obj.brand_name = BrandName.objects.get(name=request.GET.get('brandName'))
except BrandName.DoesNotExist:
return
now = datetime.datetime.now()
obj.vendor, created = Vendor.objects.get_or_create(name=request.GET.get('brand'))
obj.brand_model, created = BrandModel.objects.get_or_create(name=request.GET.get('model'))
obj.solution_type, created = SolutionType.objects.get_or_create(name=request.GET.get('device'))
obj.date_activate = now
obj.date_last_connect = now
obj.date_last_connect = now
obj.register = True
obj.licensed = False
obj.set_city_by_ip(request)
obj.save()