Esempio n. 1
0
    def save(self):
        created_user = User(first_name=self.cleaned_data.get('first_name'),
                            last_name=self.cleaned_data.get('last_name'),
                            email=self.cleaned_data.get('email'),
                            username=self.cleaned_data.get('uid'))
        created_user.set_password(self.cleaned_data.get('password'))
        created_user.save()
        created_student = Student(user=created_user,
                                  uid=self.cleaned_data.get('uid'),
                                  arn=arn_helper(
                                      self.cleaned_data.get('batch')),
                                  batch=self.cleaned_data.get('batch'))

        # created_student = Student(user=created_user,uid=created_user.username,arn=1700006,batch=2017)
        created_student.save()
        return created_student
Esempio n. 2
0
def create_super_users():
    nu = User(username='******',
              email='*****@*****.**',
              is_staff=True)
    nu.set_password('adminhassanqrsms')
    nu.is_superuser = True
    nu.is_maintainer = True
    nu.save()
    nu.groups.add(Group.objects.get(name='maintainer_group'))
    nu = User(username='******',
              email='*****@*****.**',
              is_staff=True)
    nu.set_password('adminahsanqrsms')
    nu.is_superuser = True
    nu.is_maintainer = True
    nu.save()
    nu.groups.add(Group.objects.get(name='maintainer_group'))
    return nu
Esempio n. 3
0
    def create(cls, first_name, last_name, email, password, *args, **kwargs):
        print(first_name + last_name + email + password)
        user_created = User(first_name=first_name, last_name=last_name,
                            password=password, email=email, is_student=True)
        user_created.save()
        last_student = Student.objects.all().order_by('arn').last()

        if not last_student:
            print("last student is empty")
            last_arn_number = ((17 % 100)*1000000)+1
        else:
            last_arn_number = last_student.arn + 1

        student_created = cls(user=user_created, arn=last_arn_number)

        student_created.groups.add(Group.objects.get(name='student_group'))
        print("Returning created student")
        print(student_created)

        return student_created