コード例 #1
0
    def test_authenticating_users(self):
        """Tests the authentication of users"""
        # Creates the users
        user1 = FomoUser()
        user1.first_name = 'Stephane'
        user1.last_name = 'Akoki'
        user1.set_password('baseball')
        user1.date_joined = datetime.now()
        user1.last_login = datetime.now()
        user1.username = '******'
        user1.email = '*****@*****.**'
        user1.phone = '336-486-4595'
        user1.address = '1960 N Canyon Rd'
        user1.city = 'Provo'
        user1.state = 'Utah'
        user1.zip_code = '84604'
        user1.is_superuser = True
        user1.is_staff = True
        user1.is_active = True
        user1.save()

        #pull back off of the database
        user1auth = authenticate(username=user1.username, password='******')
        u2 = FomoUser.objects.get(username='******')
        self.assertEqual(u2, user1auth)
コード例 #2
0
    def authenticate(self, username=None, password=None):
        active_directory = LDAP()
        ad_user = active_directory.authenticate(username, password)

        if ad_user != None:
            try:
                user = FomoUser.objects.get(username=ad_user.sAMAccountName)
                user.username = ad_user.sAMAccountName
                user.first_name = ad_user.givenName
                user.last_name = ad_user.sn
                user.email = str(ad_user.userPrincipalName).replace(
                    '.local', '.us')
                user.save()
            except FomoUser.DoesNotExist:
                user = FomoUser()
                user.username = ad_user.sAMAccountName
                user.first_name = ad_user.givenName
                user.last_name = ad_user.sn
                user.email = str(ad_user.userPrincipalName).replace(
                    '.local', '.us')
                user.is_staff = True
                user.save()
                group = Group.objects.get(name__exact='Managers')
                user.groups.add(group)
                cart = ShoppingCart(user=user)
                cart.save()
            return user
        return None
コード例 #3
0
g2.permissions.add(Permission.objects.get(codename=('View_products')))
g2.permissions.add(Permission.objects.get(codename=('View_users')))

for p in Permission.objects.all():
    # print(p.code)
    g3.permissions.add(p)
g3.permissions.add(Permission.objects.get(codename=('View_products')))
g3.permissions.add(Permission.objects.get(codename=('View_users')))
g3.permissions.add(Permission.objects.get(codename=('change_fomouser')))

#Query all / some with different query OPTIONS
# 3 - 5 examples

u1 = FomoUser()
u1.first_name = "Stephane"
u1.last_name = "Akoki"
u1.username = "******"
u1.set_password("jeuvideo")
u1.address = "Provo"
u1.zip = '84604'
u1.date_joined = datetime.now()
u1.last_login = datetime.now()
u1.email = "*****@*****.**"
u1.phone_number = "8013863392"
u1.city = "Provo"
u1.state = "UT"
u1.is_staff = True
u1.is_active = True
u1.save()
コード例 #4
0
ファイル: initialize.py プロジェクト: jairoadi/isyatchclub
    cursor.execute("DROP SCHEMA public CASCADE")
    cursor.execute("CREATE SCHEMA public")
    cursor.execute("GRANT ALL ON SCHEMA public TO postgres")
    cursor.execute("GRANT ALL ON SCHEMA public TO public")

# make the migrations and migrate
management.call_command('makemigrations')
management.call_command('migrate')

from account.models import FomoUser

## USERS ##

u1 = FomoUser()
u1.username = '******'
u1.first_name = 'Colby'
u1.last_name = 'Thomas'
u1.gender = 'Male'
u1.birthdate = date(1994, 6, 16)
u1.email = '*****@*****.**'
u1.password = '******'
u1.is_staff = True
u1.is_active = True
u1.date_joined = datetime.now()
u1.last_login = datetime.now()
u1.save()

u2 = FomoUser()
u2.username = '******'
u2.first_name = 'Marc'
u2.last_name = 'Oelkers'
コード例 #5
0
# c2.choice_text = 'No'
# c2.save()

# q2 = Question.objects.get(id=2)
# print(q2.id, q2.question_text)
# for c in q2.choice_set.all():
#     print(c.choice_text)
#     print(c.question.question_text)

# questions = Question.objects.filter(id__gt=0)
# for q in questions:
#     print(q.id)

u1 = FomoUser()
u1.username = '******'
u1.first_name = 'Marc'
u1.last_name = 'Oelkers'
u1.password = '******'
u1.last_login = datetime.now()
u1.birthday = datetime(1994, 12, 13)
u1.gender = 'Male'

u2 = FomoUser()
u2.username = '******'
u2.first_name = 'Shiblo'
u2.last_name = 'Pahulu'
u2.password = '******'
u2.last_login = datetime.now()
u2.birthday = datetime(1987, 07, 02)
u2.gender = 'Male'
コード例 #6
0
# c2.choice_text = 'No'
# c2.save()

# q2 = Question.objects.get(id=2)
# print(q2.id, q2.question_text)
# for c in q2.choice_set.all():
#     print(c.choice_text)
#     print(c.question.question_text)

# questions = Question.objects.filter(id__gt=0)
# for q in questions:
#     print(q.id)

u1 = FomoUser()
u1.username = '******'
u1.first_name = 'Paul'
u1.last_name = 'Pahulu'
u1.password = '******'
u1.last_login = datetime.now()
u1.birthday = datetime(1982, 7, 30)
u1.gender = 'Male'

u2 = FomoUser()
u2.username = '******'
u2.first_name = 'Chris'
u2.last_name = 'Thompkins'
u2.password = '******'
u2.last_login = datetime.now()
u2.birthday = datetime(1977, 4, 21)
u2.gender = 'Male'