def valider_repas(request): contact_detail = ContactDetail( tel="Matricule : " + str(request.user.etudiant.matricule) + '\n' + "Nom : " + str(request.user.etudiant.nom), ) context = dict( contact_detail=contact_detail, my_options=QRCodeOptions(size='t', border=6, error_correction='L'), ) return render(request, 'cossa/valider_repas.html', context=context)
def get_context_data(self, **kwargs): data = super(ThankYouView, self).get_context_data(**kwargs) order = Order.objects.all().first() user_address = order.shipping_address data['order'] = order data["contact_detail"] = ContactDetail( first_name=user_address.name, email=user_address.email, tel=user_address.phone, ) return data
def show_dashboard(request): current_site = get_current_site(request) register_url = 'http://' + current_site.domain + "/webauth/register/?introcode=" + str( request.user.introcode) contact_detail = ContactDetail(first_name=request.user.username, email=request.user.email, url=register_url) context = { "qrcode_introcode": contact_detail.url, "membertree": request.user.profile.get_descendants(include_self=True) } return render(request, "shop/accounts/dashboard.html", context)
def code(request): # Use a ContactDetail instance to encapsulate the detail of the contact. contact_detail = ContactDetail( first_name='John', last_name='Doe', first_name_reading='jAAn', last_name_reading='dOH', tel='+41769998877', email='*****@*****.**', url='http://www.company.com', birthday=date(year=1985, month=10, day=2), address='Cras des Fourches 987, 2800 Delémont, Jura, Switzerland', memo='Development Manager', org='Company Ltd', ) # Use a WifiConfig instance to encapsulate the configuration of the connexion. wifi_config = WifiConfig(ssid='my-wifi', authentication=WifiConfig.AUTHENTICATION.WPA, password='******') # Build coordinates instances. google_maps_coordinates = Coordinates(latitude=586000.32, longitude=250954.19) geolocation_coordinates = Coordinates(latitude=586000.32, longitude=250954.19, altitude=500) # Build context for rendering QR codes. context = dict( contact_detail=contact_detail, wifi_config=wifi_config, video_id='J9go2nj6b3M', google_maps_coordinates=google_maps_coordinates, geolocation_coordinates=geolocation_coordinates, options_example=QRCodeOptions(size='t', border=6, error_correction='L'), ) # Render the index page. return render(request, 'qrcode.html', context=context)
def order_details(request, invoice_id): order = get_object_or_404(Order, invoice_id=invoice_id) template_path = 'order/order_details.html' response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'filename="report.pdf"' template = get_template(template_path) customer_information = ContactDetail(first_name=order.customer_name, last_name='', tel=order.phone, email=order.email) qr_code_string = f"customer name: {order.customer_name}\nphone: {order.phone}\nemail: {order.email}" context = { 'order': order, 'qr_code_string': qr_code_string, 'customer_information': customer_information } html = template.render(context) pisa_status = pisa.CreatePDF(html, dest=response) if pisa_status.err: return HttpResponse('We had some errors <pre>' + html + '</pre>') return response
def _make_tests_data(embedded=True, image_format='svg'): contact_detail1 = dict(**TEST_CONTACT_DETAIL) contact_detail2 = ContactDetail(**contact_detail1) wifi_config1 = dict(**TEST_WIFI_CONFIG) wifi_config2 = WifiConfig(**wifi_config1) google_maps_coordinates = Coordinates(latitude=586000.32, longitude=250954.19) geolocation_coordinates = Coordinates(latitude=586000.32, longitude=250954.19, altitude=500) tag_prefix = 'qr_for_' if embedded else 'qr_url_for_' tag_args = dict(image_format=image_format) if image_format == 'png': tag_args['size'] = 't' if not embedded: # Deactivate cache for URL. tag_args['cache_enabled'] = False raw_data = ( ('email', '"*****@*****.**"', None), ('tel', ' "+41769998877"', None), ('sms', ' "+41769998877"', None), ('geolocation', 'latitude=586000.32 longitude=250954.19 altitude=500', None), ('geolocation', 'coordinates=coordinates', { 'coordinates': geolocation_coordinates }), ('google_maps', 'latitude=586000.32 longitude=250954.19', None), ('google_maps', 'coordinates=coordinates', { 'coordinates': google_maps_coordinates }), ('wifi', 'wifi_config', { 'wifi_config': wifi_config1 }), ('wifi', 'wifi_config', { 'wifi_config': wifi_config2 }), ('wifi', 'wifi_config=wifi_config', { 'wifi_config': wifi_config2 }), ('contact', 'contact_detail', { 'contact_detail': contact_detail1 }), ('contact', 'contact_detail', { 'contact_detail': contact_detail2 }), ('contact', 'contact_detail=contact_detail', { 'contact_detail': contact_detail2 }), ('youtube', '"J9go2nj6b3M"', None), ('youtube', 'video_id', { 'video_id': "J9go2nj6b3M" }), ('google_play', '"ch.admin.meteoswiss"', None), ) tests_data = [] for tag_base_name, tag_data, template_context in raw_data: test_data = TestQRForApplications._make_test_data( tag_pattern='%s%s %s' % (tag_prefix, tag_base_name, tag_data), ref_file_name='qr_for_%s' % tag_base_name, tag_args=tag_args, template_context=template_context) tests_data.append(test_data) return tests_data
def test_make_qr_code_text(self): data = dict(**TEST_CONTACT_DETAIL) c1 = ContactDetail(**data) data['nickname'] = 'buddy' c2 = ContactDetail(**data) data['last_name'] = "O'Hara;,:" data['tel_av'] = 'n/a' c3 = ContactDetail(**data) del data['last_name'] c4 = ContactDetail(**data) self.assertEqual( c1.make_qr_code_text(), r'MECARD:N:Doe,John;SOUND:dOH,jAAn;TEL:+41769998877;EMAIL:[email protected];NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;ORG:Company Ltd;;' ) self.assertEqual( c2.make_qr_code_text(), r'MECARD:N:Doe,John;SOUND:dOH,jAAn;TEL:+41769998877;EMAIL:[email protected];NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;NICKNAME:buddy;ORG:Company Ltd;;' ) self.assertEqual( c3.make_qr_code_text(), r"MECARD:N:O'Hara\;\,\:,John;SOUND:dOH,jAAn;TEL:+41769998877;TEL-AV:n/a;EMAIL:[email protected];NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;NICKNAME:buddy;ORG:Company Ltd;;" ) self.assertEqual( c4.make_qr_code_text(), r"MECARD:N:John;SOUND:dOH,jAAn;TEL:+41769998877;TEL-AV:n/a;EMAIL:[email protected];NOTE:Development Manager;BDAY:19851002;ADR:Cras des Fourches 987, 2800 Delémont, Jura, Switzerland;URL:http\://www.company.com;NICKNAME:buddy;ORG:Company Ltd;;" )
from datetime import date from django.shortcuts import render from qr_code.qrcode.utils import ContactDetail, WifiConfig, Coordinates, QRCodeOptions # Use a ContactDetail instance to encapsulate the detail of the contact. DEMO_CONTACT = ContactDetail( first_name='سلطان', last_name='10321', first_name_reading='المعاملة', last_name_reading='تاريخها', tel='+41769998877', email='رقم القيد', URL='تاريخه', birthday=date(month=5, day=16, year=1986), Nickname='1986-05-08', address='مكة', memo='نوع الإحداثي', org='محكمة مكذا', ) # Use a WifiConfig instance to encapsulate the configuration of the connexion. DEMO_WIFI = WifiConfig(ssid='my-wifi', authentication=WifiConfig.AUTHENTICATION.WPA, password='******') DEMO_COORDINATES = Coordinates(latitude=586000.32, longitude=250954.19, altitude=500) DEMO_OPTIONS = QRCodeOptions(size='t', border=6, error_correction='L')
from datetime import date from django.shortcuts import render from qr_code.qrcode.utils import ContactDetail, WifiConfig, Coordinates, QRCodeOptions # Use a ContactDetail instance to encapsulate the detail of the contact. DEMO_CONTACT = ContactDetail( first_name='John', last_name='Doe', first_name_reading='jAAn', last_name_reading='dOH', tel='+41769998877', email='*****@*****.**', url='http://www.company.com', birthday=date(year=1985, month=10, day=2), address='Cras des Fourches 987, 2800 Delémont, Jura, Switzerland', memo='Development Manager', org='Company Ltd', ) # Use a WifiConfig instance to encapsulate the configuration of the connexion. DEMO_WIFI = WifiConfig( ssid='my-wifi', authentication=WifiConfig.AUTHENTICATION.WPA, password='******' ) DEMO_COORDINATES = Coordinates(latitude=586000.32, longitude=250954.19, altitude=500) DEMO_OPTIONS = QRCodeOptions(size='t', border=6, error_correction='L')
def resumedownload(request): # profile1 = Profile.objects.all() # """Generate pdf.""" first_name = request.POST.get('first_name') last_name = request.POST.get('last_name') nphone1 = request.POST.get('nphone1') nphone2 = request.POST.get('nphone2') email = request.POST.get('email') inputDriverslicense = request.POST.get('inputDriverslicense') address = request.POST.get('address') birthdate = request.POST.get('datapicker') neighborHood = request.POST.get('neighborHood') city = request.POST.get('city') state = request.POST.get('state') zip = request.POST.get('zip') inputmaritalStatus = request.POST.get('inputmaritalStatus') inputlevelStudy1 = request.POST.get('inputlevelStudy1') lInstitution1 = request.POST.get('lInstitution1') lyearFinish1 = request.POST.get('lyearFinish1') inputlevelStudy2 = request.POST.get('inputlevelStudy2') lInstitution2 = request.POST.get('lInstitution2') lyearFinish2 = request.POST.get('lyearFinish2') inputlevelStudy3 = request.POST.get('inputlevelStudy3') lInstitution3 = request.POST.get('lInstitution3') lyearFinish3 = request.POST.get('lyearFinish3') inputlevelStudy4 = request.POST.get('inputlevelStudy4') lInstitution4 = request.POST.get('lInstitution4') lyearFinish4 = request.POST.get('lyearFinish4') course1 = request.POST.get('course1') cInstitution1 = request.POST.get('cInstitution1') cyearFinish1 = request.POST.get('cyearFinish1') studyTime1 = request.POST.get('studyTime1') course2 = request.POST.get('course2') cInstitution2 = request.POST.get('cInstitution2') cyearFinish2 = request.POST.get('cyearFinish2') studyTime2 = request.POST.get('studyTime2') course3 = request.POST.get('course3') cInstitution3 = request.POST.get('cInstitution3') cyearFinish3 = request.POST.get('cyearFinish3') studyTime3 = request.POST.get('studyTime3') course4 = request.POST.get('course4') cInstitution4 = request.POST.get('cInstitution4') cyearFinish4 = request.POST.get('cyearFinish4') studyTime4 = request.POST.get('studyTime4') company1 = request.POST.get('company1') function1 = request.POST.get('function1') worktime1 = request.POST.get('worktime1') functionDescribe1 = request.POST.get('functionDescribe1') company2 = request.POST.get('company2') function2 = request.POST.get('function2') worktime2 = request.POST.get('worktime2') functionDescribe2 = request.POST.get('functionDescribe2') company3 = request.POST.get('company3') function3 = request.POST.get('function3') worktime3 = request.POST.get('worktime3') functionDescribe3 = request.POST.get('functionDescribe3') company4 = request.POST.get('company4') function4 = request.POST.get('function4') worktime4 = request.POST.get('worktime4') functionDescribe4 = request.POST.get('functionDescribe4') #TODO this work , save picture on server, ERROR if don't login. # if request.method == 'POST': # # picResume = updatePicResumeForm( data=request.POST, files=request.FILES , instance=request.user) # picResume = updateImageResumeForm(data=request.POST, files=request.FILES, instance=request.user.profile) # if picResume.is_valid(): # picResume.save() contact_detail = ContactDetail( first_name=first_name, last_name=last_name, tel=nphone1, email=email, # url='http://www.company.com', ) # print (picResume) context = { 'first_name': first_name, 'last_name': last_name, 'nphone1': nphone1, 'nphone2': nphone2, 'email': email, 'inputDriverslicense': inputDriverslicense, 'birthdate': birthdate, 'address': address, 'neighborHood': neighborHood, 'city': city, 'state': state, 'zip': zip, 'inputmaritalStatus': inputmaritalStatus, 'inputlevelStudy1': inputlevelStudy1, 'lInstitution1': lInstitution1, 'lyearFinish1': lyearFinish1, 'inputlevelStudy2': inputlevelStudy2, 'lInstitution2': lInstitution2, 'lyearFinish2': lyearFinish2, 'inputlevelStudy3': inputlevelStudy3, 'lInstitution3': lInstitution3, 'lyearFinish3': lyearFinish3, 'inputlevelStudy4': inputlevelStudy4, 'lInstitution4': lInstitution4, 'lyearFinish4': lyearFinish4, 'course1': course1, 'cInstitution1': cInstitution1, 'cyearFinish1': cyearFinish1, 'studyTime1': studyTime1, 'course2': course2, 'cInstitution2': cInstitution2, 'cyearFinish2': cyearFinish2, 'studyTime2': studyTime2, 'course3': course3, 'cInstitution3': cInstitution3, 'cyearFinish3': cyearFinish3, 'studyTime3': studyTime3, 'course4': course4, 'cInstitution4': cInstitution4, 'cyearFinish4': cyearFinish4, 'studyTime4': studyTime4, 'company1': company1, 'function1': function1, 'worktime1': worktime1, 'functionDescribe1': functionDescribe1, 'company2': company2, 'function2': function2, 'worktime2': worktime2, 'functionDescribe2': functionDescribe2, 'company3': company3, 'function3': function3, 'worktime3': worktime3, 'functionDescribe3': functionDescribe3, 'company4': company4, 'function4': function4, 'worktime4': worktime4, 'functionDescribe4': functionDescribe4, 'contact_detail': contact_detail } return render(request, 'pdfmodels/resumedownload.html', context) #open Html A4