Skip to content

Commit

Permalink
Friday Update
Browse files Browse the repository at this point in the history
  • Loading branch information
agent87 committed Nov 12, 2021
1 parent a550893 commit 6185c02
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 14 deletions.
15 changes: 15 additions & 0 deletions DashboardApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,18 @@ def add_user(request):
return redirect(reverse('user_page'))
else:
return redirect(reverse('user_page'))

class Subscribers:
@login_required
def add_subscriber(request):
if request.method == "POST":
platenum = request.POST.get('platenum')
phonenum = request.POST.get('phonenum')
office = request.POST.get('office')
parklot = request.POST.get('parklot')
start_date = request.POST.get('start_date')
end_date = request.POST.get('end_date')
models.Subscribers.add_subscriber(platenum, phonenum, office, parklot, start_date, end_date)
return redirect(reverse('subscribers_page'))
else:
return redirect(reverse('subscribers_page'))
Binary file added Ewawe_Systems/Ewawe Parking Systems.lnk
Binary file not shown.
45 changes: 31 additions & 14 deletions SystemApp/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.hashers import make_password
from django.db import models
from django.utils.translation import ugettext_lazy as _
from uuid import uuid4
Expand Down Expand Up @@ -42,15 +43,14 @@ def __str__(self):

@classmethod
def add_user(self, first_name, last_name, email, phonenum, password, role):
self.objects.create(email=email,
password=password,
self.objects.create(email=email,
customer_id=Customers.objects.get(customer_id='EPMS-0001'),
first_name=first_name,
last_name=last_name,
role = role,
password = make_password(password),
phonenum=phonenum)
return self.objects.get(email=email)


@classmethod
def create_admin(self, email, password, customer_id, fname, lname, contact):
self.objects.create(email=email, password=password, customer_id=customer_id, fname=fname, lname=lname, contact=contact, is_superuser=1)
Expand Down Expand Up @@ -158,15 +158,32 @@ def remove_tarrif(self, tarrifid):
self.objects.filter(tarrifid=tarrifid).delete()


class Subcription:
customer_id = models.CharField(db_column='CustomerId', max_length=50) # Field name made lowercase.
class Subcriptions:
customer_id = models.ForeignKey(Customers, on_delete=models.CASCADE, blank=True, null=True)
subscription_id = models.CharField(db_column='SubscriptionId', max_length=50) # Field name made lowercase.
platenumber = models.CharField(db_column='PlateNumber', max_length=50) # Field name made lowercase.
subscription_date = models.DateField(db_column='SubscriptionDate') # Field name made lowercase.
subscription_end_date = models.DateField(db_column='SubscriptionEndDate') # Field name made lowercase.
subscription_type = models.CharField(db_column='SubscriptionType', max_length=50) # Field name made lowercase.
subscription_status = models.CharField(db_column='SubscriptionStatus', max_length=50) # Field name made lowercase.
subscription_amount = models.FloatField(db_column='SubscriptionAmount') # Field name made lowercase.
contact_number = models.CharField(db_column='ContactNumber', max_length=50) # Field name made lowercase.
office_location = models.CharField(db_column='OfficeLocation', max_length=50) # Field name made lowercase.
parkingLot = models.CharField(db_column='ParkingLot', max_length=50) # Field name made lowercase.
start_date = models.DateField(db_column='SubscriptionDate') # Field name made lowercase.
end_date = models.DateField(db_column='SubscriptionEndDate') # Field name made lowercase.
type = models.CharField(db_column='SubscriptionType', max_length=50)
amount = models.FloatField(db_column='SubscriptionAmount') # Field name made lowercase.
phonenum = models.CharField(db_column='ContactNumber', max_length=50) # Field name made lowercase.
office = models.CharField(db_column='OfficeLocation', max_length=50) # Field name made lowercase.
parklot = models.CharField(db_column='ParkingLot', max_length=50) # Field name made lowercase.

class Meta:
db_table = 'Subscription'

@classmethod
def add_subscription(self, customer_id, subscription_id, platenum, start_date, end_date, type, amount, phonenum, office, parklot):
self.objects.create(
customer_id = customer_id,
subscription_id = subscription_id,
platenumber = platenum,
start_date = start_date,
end_date = end_date,
type = type,
amount = amount,
phonenum = phonenum,
office = office,
parklot = parklot
)

0 comments on commit 6185c02

Please sign in to comment.