示例#1
0
    def form_valid(self, form, **kwargs):
        user = User()
        user.name = form.cleaned_data['name']
        user.email = form.cleaned_data['email']
        user.phone = form.cleaned_data['phone']
        user.mobile_phone = form.cleaned_data['mobile_phone']
        user.status = form.cleaned_data['status']
        user.save()

        context = self.get_context_data(**kwargs)
        messages.add_message(self.request, messages.INFO, 'User created successfully')

        return render(self.request, self.get_template_names(), context=context)
示例#2
0
    def test_update_user(self):
        u = User(name="unknown", email="*****@*****.**", status="inactive")
        _id = u.save()

        u = User.get(id=_id)
        self.assertEqual(u.name, 'unknown', 'User name')
        self.assertEqual(u.email, '*****@*****.**', 'User email')
        self.assertEqual(u.status, 'inactive', 'User status')

        u.name = 'Michael Cimino'
        u.update()
        u = User.get(id=_id)
        self.assertEqual(u.name, 'Michael Cimino', 'Update user name')
        self.assertEqual(u.email, '*****@*****.**', 'Update user email')
        self.assertEqual(u.status, 'inactive', 'Update user status')

        u.email = "*****@*****.**"
        u.update()
        u = User.get(id=_id)
        self.assertEqual(u.name, 'Michael Cimino', 'Update user name')
        self.assertEqual(u.email, '*****@*****.**', 'Update user email')
        self.assertEqual(u.status, 'inactive', 'Update user status')

        u.status = 'active'
        u.update()
        u = User.get(id=_id)
        self.assertEqual(u.name, 'Michael Cimino', 'Update user name')
        self.assertEqual(u.email, '*****@*****.**', 'Update user email')
        self.assertEqual(u.status, 'active', 'Update user status')

        self.assertIsNone(u.phone, "User phone is not null")
        u.phone = '+380123456789'
        u.update()
        u = User.get(id=_id)
        self.assertEqual(u.phone, '+380123456789', 'Update user phone')

        self.assertIsNone(u.mobile_phone, "User mobile phone is not null")
        u.mobile_phone = '+389876543210'
        u.update()
        u = User.get(id=_id)
        self.assertEqual(u.mobile_phone, '+389876543210',
                         'Update user mobile phone')
interest.description = 'How to build an Internet business'
interest.create_interest()
startup_id = interest.id

interest = Interest()
interest.name = 'Python Programming'
interest.description = 'Programming with the Python language'
interest.create_interest()
python_id = interest.id


#USERS
#Marnee, Julian, Chris, Dan, Liz, Frank
marnee = User()
marnee.call_sign = 'AWESOME'
marnee.email = '*****@*****.**'
marnee.name = 'Marnee'
marnee.is_admin = True
marnee.about = 'This is about me.'
marnee.mission_statement = 'This is my mission statement.'
marnee.create_user()

julian = User()
julian.call_sign = 'RADICAL'
julian.email = '*****@*****.**'
julian.name = 'Julian'
julian.is_admin = False
julian.about = 'This is about me.'
julian.mission_statement = 'This is my mission statement.'
julian.create_user()
示例#4
0
 def get_user_by_email(email):
     user = User()
     user.email = email
     user.get_user()
     return user