I have an employee model entailing the below
class Employee(models.Model):
STATUS = (
('Active', 'Active'),
('Blocked', 'Blocked'),
)
ROLE = (
('Employee', 'Employee'),
('User', 'User'),
)
name = models.CharField(max_length=200, null=True)
email = models.CharField(max_length=200, null=True)
password = models.CharField(max_length=200, null=True)
status = models.CharField(max_length=200, null=True,choices=STATUS)
role = models.CharField(max_length=200, null=True, choices=ROLE)
def __str__(self):
return self.first_name
views shown below the update and new form of employee
@login_required(login_url='login')
def deleteProfile(request, pk):
employee = Employee.objects.get(id=pk)
if request.method == "POST":
employee.delete()
return redirect('/')
return render(request, 'accounts/delete_profile.html', 'employee':employee)
@login_required(login_url='login')
def NewEmployeeProfile(request):
form = EmployeeProfileForm()
if request.method == 'POST':
form = EmployeeProfileForm(request.POST or None)
if form.is_valid():
form.save()
return redirect('/')
return render(request, 'accounts/new_employee_profile.html', {'form': form})
As a superuser I would like to have the decision of allocating an employee either the role of User or employee. (Any User can be able to do this once logged in) When having to update or create an employee
Also as a superuser I would like to allocate whether the employee/User has an blocked or active account (so allowing them access when they log in or not) also when having to create an employee (Any User can be able to do this once logged in)
How will this be reflected on to the view.py when it is either updated or created?