Ejemplo n.º 1
0
    def get(self, request):
        data = {}
        data['page_title'] = 'users'
        data['users'] = User.objects.all_user()

        # dump_data = dd(request, data['users'])
        # return HttpResponse(dump_data)

        # data['qr_code_message'] = 'Hello World! I am Rakib.'
        # Use a WifiConfig instance to encapsulate the configuration of the connexion.
        data['wifi_config'] = WifiConfig(
            ssid='my-wifi',
            authentication=WifiConfig.AUTHENTICATION.WPA,
            # password='******',
            password='******',
        )
        data['qr_code_options'] = QRCodeOptions(size='10',
                                                border=6,
                                                error_correction='L')
        template = 'pages/user_list.html'

        # response = serializers.serialize('json', data['users'])
        # # response = serializers.serialize('json', data['users'], fields=('first_name','last_name','email'))
        # return HttpResponse(response)

        return render(request, template, data)
Ejemplo n.º 2
0
def credentials_sheet_view(request):
    if settings.DEBUG or request.user.groups.filter(
            name=SPIELLEITUNG).exists():

        if request.is_secure():
            base_url = 'https://'
        else:
            base_url = 'http://'
        base_url += request.get_host()

        userqueryset = get_user_model().objects.exclude(
            groups__name=SPIELLEITUNG)

        users = []
        for user in userqueryset.filter(groups__name=KUNDEN):
            users.append(user)
        for user in userqueryset.filter(groups__name=JOGA):
            users.append(user)
        for user in userqueryset.filter(groups__name=LIEFERANTEN):
            users.append(user)

        userdict = []
        for user in users:
            password = str(
                int(
                    hashlib.sha256(user.username.encode('utf-8')).hexdigest(),
                    16) % 10**4)
            credentials = {
                'user':
                user,
                'password':
                password,
                'company':
                user.groups.filter(
                    name__in=[KUNDEN, JOGA, LIEFERANTEN]).first().name,
                'group':
                user.groups.exclude(
                    name__in=[KUNDEN, JOGA, LIEFERANTEN, SPIELLEITUNG
                              ]).first().name,
                'login_url':
                base_url + reverse('urllogin',
                                   kwargs={
                                       'username': user.username,
                                       'password': password
                                   }),
                'site':
                base_url + '/',
            }
            userdict.append(credentials)

        wifi_config = WifiConfig(ssid='PLANSPIEL',
                                 authentication=WifiConfig.AUTHENTICATION.WPA,
                                 password='******')

        c = {'users': userdict, 'wifi_config': wifi_config}

        return render(request, "registration/credentials_sheet.html", c)
    else:
        return HttpResponse('Unauthorized', status=401)
Ejemplo n.º 3
0
 def test_make_qr_code_text(self):
     wifi1 = WifiConfig(**TEST_WIFI_CONFIG)
     wifi2 = WifiConfig(hidden=True, **TEST_WIFI_CONFIG)
     self.assertEqual(wifi1.make_qr_code_text(),
                      'WIFI:S:my-wifi;T:WPA;P:wifi-password;;')
     self.assertEqual(wifi2.make_qr_code_text(),
                      'WIFI:S:my-wifi;T:WPA;P:wifi-password;H:true;;')
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
 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
Ejemplo n.º 6
0
    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')

IMG_LIST = {"brand": "Ford", "model": "Mustang", "year": 1964}


def index(request):
    """
    Build the home page of this demo app.