Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/signup #75

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Saksham-1508
Copy link
Contributor

New signup workflow.

# CREATING THE USER FROM THE MODEL FORM DATA
user = form.save(commit=False)
user.username = form.cleaned_data.get('username')
user.email = str(form.cleaned_data.get('email'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you do not need to do this (above two lines). It is already taken care of by django forms. So, if you keep is_active=False as default, you can just do form.save() here?

request.user.first_name = first_name
request.user.last_name = last_name
request.user.is_active = False
profile.save()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding all this information manually, why not just do form.save() here?? You can use reg_no_gen first thing after if request.method == 'POST', something like request.POST['reg_no'] = reg_no_gen(...).


class Batch(models.Model):
# batch = models.IntegerField(primary_key=True,choices=Constants.BATCH_OF,default=2009)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this commented line.

batch = models.IntegerField(primary_key=True)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove newlines like this. It reduces readability of the code.

roll_no = models.IntegerField(primary_key=True)
email = models.EmailField(null=False, default="")
alternate_email = models.EmailField(null=True, blank=True)
roll_no = models.CharField(primary_key=True,max_length=8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't assume that the max_length will always be 8 only, keep it 10 or 15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants