Skip to content

Commit

Permalink
New Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
agent87 committed Jan 25, 2022
1 parent 2781419 commit 6befa33
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DashboardApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def RegisterView(request):

def register(request):
try:
customer = models.Customers.enroll_customer(company_name=request.POST.get('customer_name'), address = request.POST.get('address'), comments=None)
customer = models.Customers.enroll_customer(company_name=request.POST.get('customer_name'), address = request.POST.get('address'))
if customer[0]:
try:
User = models.Users.add_user(customer[1].customer_id, request.POST.get('first_name'), request.POST.get('last_name'), request.POST.get('email'), request.POST.get('phonenum'), request.POST.get('password'), 'Admin')
Expand Down
13 changes: 6 additions & 7 deletions SystemApp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
class Customers(models.Model):
customer_id = models.SmallAutoField(db_column='CustomerId', primary_key=True, editable=False)
#administrator = models.ForeignKey('Users', on_delete=models.CASCADE, blank=True, null=True)
company_name = models.CharField(db_column='CompanyName', max_length=50, blank=True, null=True)
company_name = models.CharField(db_column='CompanyName', max_length=50 )
address = models.CharField(db_column='Address', max_length=50, blank=True, null=True)
comments = models.CharField(db_column='Comments', max_length=500, blank=True, null=True)
enrollment_date = models.DateField(blank=True, null=True)
enrollment_date = models.DateField(blank=True, default=datetime.date.today)

class Meta:
db_table = 'Customers'
Expand All @@ -30,8 +29,8 @@ def __str__(self):
return self.company_name

@classmethod
def enroll_customer(self, company_name, address, comments):
self.objects.create(company_name=company_name, address=address, comments=comments, enrollment_date=datetime.date.today())
def enroll_customer(self, company_name, address):
self.objects.create(company_name=company_name, address=address, enrollment_date=datetime.date.today())
return True, self.objects.latest('customer_id')


Expand Down Expand Up @@ -130,9 +129,9 @@ def add_user(self, customer_id, first_name, last_name, email, phonenum, password
''', [email])

return True, self.objects.latest('user_id')
return True, self.objects.latest('user_id'), None
except IntegrityError:
return False, 'Email already exists'
return False, None, 'Email already exists'

@property
def total_entries(self):
Expand Down
3 changes: 0 additions & 3 deletions SystemApp/tests.py

This file was deleted.

3 changes: 0 additions & 3 deletions SystemApp/views.py

This file was deleted.

0 comments on commit 6befa33

Please sign in to comment.