Skip to content

Commit

Permalink
Camera API
Browse files Browse the repository at this point in the history
  • Loading branch information
agent87 committed Nov 22, 2021
1 parent fd1fe84 commit be1657c
Show file tree
Hide file tree
Showing 18 changed files with 607 additions and 106 deletions.
Empty file added API/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions API/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions API/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'API'
9 changes: 9 additions & 0 deletions API/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.db import models

# Create your models here.

# class Requests(models.Model):
# request_id = models.AutoField(primary_key=True)
# request_name = models.CharField(max_length=50)
# request_description = models.CharField(max_length=200)
# request_status = models.CharField(max_length=50)
3 changes: 3 additions & 0 deletions API/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions API/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path
from . import views



urlpatterns = [
###Auth Related#####
path('post', views.ParkingLogs.Post, name='ParkingLogs_Port')
]
38 changes: 38 additions & 0 deletions API/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.core.exceptions import ObjectDoesNotExist
from requests.api import request
import SystemApp
import datetime
from uuid import uuid4


class ParkingLogs:
@csrf_exempt
def Post(request):
if request.method == 'POST':
if request.POST.get('flow') == 'entry':
ticket_id = uuid4()
SystemApp.models.Parkinglog.objects.create(plate_number=request.POST.get('plate_number'),
date = datetime.datetime.now(),
ticket_id = ticket_id,
customer_id = SystemApp.models.Customers.objects.get(customer_id=request.POST.get('customer_id')),
checkin_time= int(float(request.POST.get('time'))),
checkin_method = 'Camera',
entry_gate= SystemApp.models.Gates.objects.get(gate_id=request.POST.get('gate')),
parked = True)

try:
SystemApp.models.Parkinglog.objects.filter(ticket_id=ticket_id).update(subscription=SystemApp.models.Subscriptions.objects.get(plate_number=request.POST.get('plate_number')))
except ObjectDoesNotExist:
pass
response = HttpResponse()
response['TicketId'] = ticket_id
return response

else:
response = HttpResponse()
response['TicketId'] = 200
return response
else:
return None
373 changes: 373 additions & 0 deletions DashboardApp/templates/DashboardApp/Accounts/Profile.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions DashboardApp/templates/DashboardApp/Accounts/UserForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ <h5 class="title" id="defaultModalLabel"> Add New User</h4>
<div class="form-group col-sm-12">
<input id="PasswordField" name="password" type="password" class="form-control" placeholder="Password">
</div>
<label for="sel1">Phone Number</label>
<label for="phone_num">Phone Number</label>
<div class="form-group col-sm-12">
<input id="PhoneNumField" name="phonenum" type="number" class="form-control" placeholder="Phone">
</div>
<label for="sel1">Role</label>
<select class="form-control" >
<label for="role">Role</label>
<select class="form-control" name="role" >
<option selected="selected">Cashier</option>
<option>Admin</option>
</select>
Expand Down
7 changes: 6 additions & 1 deletion DashboardApp/templates/DashboardApp/Accounts/contact-us.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>Contact us</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item"><a href="{% url 'dashboard_page' %}">Home</a></li>
<li class="breadcrumb-item active">Contact us</li>
</ol>
</div>
Expand All @@ -34,6 +34,11 @@ <h1>Contact us</h1>
<div class="card-body row">
<div class="col-5 text-center d-flex align-items-center justify-content-center">
<div class="">
<div class="text-center">
<img class="profile-user-img img-fluid "
src="{% static 'logo.png' %}"
alt="User profile picture">
</div>
<h2>Ewawe<strong>Ltd</strong></h2>
<p class="lead mb-5">KG 652 St, Rugando, Kigali, Rwanda<br>
Phone: +250 785 520 477/+250 781 918 365
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ <h3 class="card-title">Checkout Form</h3>
</div>
<!-- /.card-body -->
<div class="card-footer">
<button type="button" href={% url 'parked_page' %} class="btn btn-warning">Back to Parking Logs</button>
<a href="{% url 'parked_page' %}" class="btn btn-primary float-left"><b>Back to Parking Logs</b></a>
<button type="submit" class="btn btn-info float-right">Close Ticket</button>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h3 class="card-title">Parking Logs</h3>
{% endif %}
<!-- Subscription Status -->
{% if parking_log.subcription %}
<td><span class="badge badge-success">Active</span></td>
<td><span class="badge badge-success text-center">Active</span></td>
{% else %}
<td></td>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion DashboardApp/templates/DashboardApp/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</li>
<li class="nav-header">MISCELLANEOUS</li>
<li class="nav-item">
<a href="users" class="nav-link">
<a href="{% url 'self_profile' %}" class="nav-link">
<i class="nav-icon fas fa-user-cog"></i>
<p>My Profile</p>
</a>
Expand Down
2 changes: 2 additions & 0 deletions DashboardApp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

path('accounts', views.responses.user_page, name='accounts_page'),
path('accounts/add', views.users.add_user, name='add_account'),
path('accounts/profile', views.users.self_profile, name='self_profile'),


path('contact-us', views.contact_us.contact_us_page, name='contact_us_page'),

Expand Down
15 changes: 14 additions & 1 deletion DashboardApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,18 @@ def add_user(request):
else:
return redirect(reverse('accounts_page'))

@login_required
def self_profile(request):
context = {'user': request.user}
return render(request, 'DashboardApp/Accounts/Profile.html', context)

@login_required
def user_profile(request, user_id):
context = {'user': models.Users.objects.get(user_id=user_id)}
return render(request, 'DashboardApp/Accounts/Profile.html', context)



class subscription:
@login_required
def subscribers_page(request):
Expand All @@ -179,6 +191,7 @@ def subscribers_page(request):
@login_required
def add_subscription(request):
if request.method == "POST":
user_id = request.user.user_id
customer_id = request.user.customer_id.customer_id
platenum = request.POST.get('platenum')
name = request.POST.get('name')
Expand All @@ -188,7 +201,7 @@ def add_subscription(request):
amount = request.POST.get('amount')
start_date = request.POST.get('start_date')
end_date = request.POST.get('end_date')
models.Subscriptions.add_subscription(customer_id, platenum, name, phonenum, office, parklot, amount, start_date, end_date)
models.Subscriptions.add_subscription(user_id, customer_id, platenum, name, phonenum, office, parklot, amount, start_date, end_date)
return redirect(reverse('subscribers_page'))
else:
return redirect(reverse('subscribers_page'))
Expand Down
3 changes: 2 additions & 1 deletion System/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
# Application definition

INSTALLED_APPS = [
'AuthenticationApp.apps.AuthenticationappConfig',
#'AuthenticationApp.apps.AuthenticationappConfig',
'API.apps.ApiConfig',
'DashboardApp.apps.DashboardappConfig',
'SystemApp.apps.SystemappConfig',
#Native Application
Expand Down
3 changes: 1 addition & 2 deletions System/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
urlpatterns = [
#path('auth', include('AuthenticationApp.urls')),
path('', include('DashboardApp.urls')),
#path('api', include('API.urls')),
path('api/', include('API.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS[0])

print(settings.STATICFILES_DIRS)
Loading

0 comments on commit be1657c

Please sign in to comment.