First flask push

This commit is contained in:
Alexander Hosking 2017-01-12 08:06:39 -05:00
parent 65bdeedba2
commit b58bc5cc1b
13 changed files with 462 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.pyc
env/

11
run_site.py Normal file
View File

@ -0,0 +1,11 @@
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "HEllo"
@app.route('/test')
def test():
return render_template('test.html')

View File

@ -0,0 +1,17 @@
{% extends "layout.html" %}
{% block body %}
<h1>Add Department(s)</h1>
<form action="{{ url_for('insert_department') }}" method="post">
<div class="form-group col-xs-8">
<label for="first_name">Name:</label>
<input type="text" class="form-control" id="department_name" name="department_name" placeholder="Department Name">
</div>
<div class="form-group col-xs-4">
<label for="last_name">Custom ID:</label>
<input type="text" class="form-control" id="department_id" name="department_id" placeholder="Department ID">
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
{% endblock %}

View File

@ -0,0 +1,26 @@
{% extends "layout.html" %}
{% block body %}
<h1>Add Employee </h1>
<form action="{{ url_for('insert_employee') }}" method="post">
<div class="form-group col-xs-4">
<label for="first_name">First Name:</label>
<input type="text" class="form-control" id="first_name" name="first_name" placeholder="First Name">
</div>
<div class="form-group col-xs-4">
<label for="last_name">Last Name:</label>
<input type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name">
</div>
<div class="form-group col-xs-4">
<label for="department">Department:</label>
<select title="department" name="department">
{% for department in departments %}
<option>{{ department.name }}</option>
{% endfor %}
</select>
<!--<input type="text" class="form-control" id="department" name="department" placeholder="Department">-->
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
{% endblock %}

46
templates/add_time.html Normal file
View File

@ -0,0 +1,46 @@
{% extends "layout.html" %}
{% block body %}
<h1>Add Time</h1>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
<form action="{{ url_for('insert_time') }}" method="post">
<table class="table table-bordered">
<tr>
<th>Employee</th>
<th>Start Date</th>
<th>Start Time</th>
<th>End Date</th>
<th>End Time</th>
</tr>
<tr class="time_entries">
<td>
<select title="employee" name="employee">
{% for employee in employees %}
<option value="{{employee.id}}">{{ employee.first_name }} {{employee.last_name}}</option>
{% endfor %}
</select>
</td>
<td><input type="date" name="date_start" id="date_start" class="datePicker"></td>
<td><input type="time" name="start_time" id="start_time"></td>
<td><input type="date" name="date_end" id="date_end" class="datePicker"></td>
<td><input type="time" name="end_time" id="end_time"></td>
<td><button type="submit" class="btn btn-default">Add Time</button></td>
</tr>
</table>
</form>
<!--<script>-->
<!--$(document).ready( function() {-->
<!--var now = new Date();-->
<!--var today = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();-->
<!--$('#datePicker').val(today);-->
<!--});-->
<!--</script>-->
{% endblock %}

19
templates/base.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><Test</title>
</head>
<body>
{% block content %}{% endblock %}
{% block body %}{% endblock %}
</body>
<!--Footer-->
<footer class="footer">
<div class="container">
<p class="text-muted">Inventory 1.0 (c)<a href="https://www.ahoskingit.com">AHoskingIT</a></p>
</div>
</footer>
</html>

View File

@ -0,0 +1,48 @@
{% extends "layout.html" %}
{% block body %}
<h1>Department(s)</h1>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<ul class=flashes>
{% for category, message in messages %}
<li class="{{ category }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% if departments %}
<h2>Add</h2>
<form action="{{ url_for('insert_department') }}" method="post">
<div class="form-group col-xs-8">
<label for="first_name">Name:</label>
<input type="text" class="form-control" id="department_name" name="department_name" placeholder="Department Name">
</div>
<div class="form-group col-xs-4">
<label for="last_name">Custom ID:</label>
<input type="text" class="form-control" id="department_id" name="department_id" placeholder="Department ID">
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
<h2>View</h2>
<table class="table table-condensed table-bordered table-striped">
<tr>
<th>Department Name</th>
<th>Department Code</th>
<th>Number of Employees</th>
</tr>
{% for department in departments %}
<tr>
<td>{{ department.name }}</td>
<td>{{ department.code }}</td>
<td></td>
<td><a href="{{ url_for('delete_department', id=department.id) }}">Delete</a></td>
</tr>
{% endfor %}
</table>
{% else %}
<b>There is no data in department land!</b>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,61 @@
{% extends "layout.html" %}
{% block body %}
<h1>Employees</h1>
<br>
<!--Add Employee Form-->
<h3>Add Employee</h3>
<form action="{{ url_for('insert_employee') }}" method="post">
<div class="form-group col-xs-4">
<label for="first_name">First Name:</label>
<input type="text" class="form-control" id="first_name" name="first_name" placeholder="First Name">
</div>
<div class="form-group col-xs-4">
<label for="last_name">Last Name:</label>
<input type="text" class="form-control" id="last_name" name="last_name" placeholder="Last Name">
</div>
<div class="form-group col-xs-4">
<label for="department">Department:</label>
<select title="department" name="department" class="form-control">
{% for department in departments %}
<option>{{ department.name }}</option>
{% endfor %}
<option disabled="true">------------------</option>
<option><a href="{{ url_for('add_department') }}">Create Department</a></option>
</select>
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
<!--End of Add Employee Form-->
<br>
{% if employees %}
<table class="table table-bordered table-striped">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Department</th>
<th>Project(s)</th>
<th>Time Logged</th>
</tr>
{%for employee in employees %}
<tr>
<td>{{employee.first_name}}</td>
<td>{{employee.last_name}}</td>
<td>{{employee.department}}</td>
<td>{{employee.projects}}</td>
<td></td>
<td><a href="{{ url_for('employee_edit', id=employee.id) }}">Edit</a> / <a href="{{ url_for('employee_delete', id=employee.id) }}">Delete</a></td>
</tr>
<ul>
{% if employee.description %}
<li>{{ employee.user_group }}</li>
<li>{{ employee.description }}</li>
{% endif %}
</ul>
{% endfor %}
</table>
{% endif %}
{% endblock %}

38
templates/index.html Normal file
View File

@ -0,0 +1,38 @@
{% extends "layout.html" %}
{% block body %}
<h1>Timesheet</h1>
<h2>Bugs</h2>
<ul>
<li><s>Can add time entry where end date is before start date</s></li>
</ul>
<h2>To-do</h2>
<ul>
<li>Multi-line time adds</li>
<li>Time adding from files(Toggl)</li>
<li>Associate Time with Project</li>
<li>Task types</li>
<li>Add Security Module</li>
<li>In-line editing</li>
<li>Breadcrumb</li>
<li>Secure execution via API</li>
<li>Test Cases</li>
<ul>
<li>Blank entries</li>
<ul>
<s><li>Users</li></s>
<li>Time entries</li>
</ul>
<li>Adding time in the future should not be allowed</li>
</ul>
<li>In-Page notifications for actions</li>
<ul>
<li>Adding Users</li>
<li>Deleting Users</li>
<li>Adding Time</li>
<li>Deleting Time</li>
<li>Prompt to verify desire to delete a record</li>
</ul>
</ul>
{% endblock %}

80
templates/layout.html Normal file
View File

@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Timesheet</title>
<!-- Bootstrap -->
<link href="{{ url_for('static', filename='jquery-ui.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ url_for('static', filename='timesheet.css') }}" rel="stylesheet">
</head>
<script src="{{ url_for('static', filename='jquery-2.1.4.min.js') }}"></script>
<script src="{{ url_for('static', filename='jquery-ui.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<body>
<body>
<div class="container">
<!-- Static navbar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Timesheet</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/">Home</a></li>
<!--<li class="dropdown">-->
<li>
<a href="{{ url_for('employees_index') }}" role="button">Employees</a>
</li>
<!--<ul class="dropdown-menu">-->
<!--<li><a href="/employees">View Employees</a></li>-->
<!--<li><a href="/add_employee">Add Employee</a></li>-->
<!--</ul>-->
<!--</li>-->
<li><a href="/departments">Departments</a></li>
<li>
<a href="{{ url_for('projects_show') }}" role="button">Projects</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Time<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/time">Time Reporting</a></li>
<li><a href="/add_time">Add Time</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</nav>
<!--{% with messages = get_flashed_messages() %}-->
<!--{% if messages %}-->
<!--<ul class=flashes>-->
<!--{% for message in messages %}-->
<!--<li>{{ message }}</li>-->
<!--{% endfor %}-->
<!--</ul>-->
<!--{% endif %}-->
<!--{% endwith %}-->
{% block body %}{% endblock %}
{% block footer %} {% endblock %}
</div> <!-- /container -->
</body>
</html>

View File

@ -0,0 +1,47 @@
{% extends "layout.html" %}
{% block body %}
<h1>Add Project(s)</h1>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class=flashes>
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
<form action="{{ url_for('projects_insert') }}" method="post">
<div class="form-group col-xs-8">
<label for="first_name">Name:</label>
<input type="text" class="form-control" id="project_name" name="project_name" placeholder="Project Name">
</div>
<div class="form-group col-xs-4">
<label for="last_name">Custom ID:</label>
<input type="text" class="form-control" id="project_id" name="project_id" placeholder="Project ID">
</div>
<button type="submit" class="btn btn-default">Create</button>
</form>
{% if projects %}
<h2>View</h2>
<table class="table table-condensed table-bordered table-striped">
<tr>
<th>Project Name</th>
<th>Project ID</th>
<th>Number of Employees</th>
</tr>
{% for project in projects %}
<tr>
<td>{{ project.project_name }}</td>
<td>{{ project.project_id }}</td>
<td></td>
<td><a href="{{ url_for('projects_delete', id=project.id) }}">Delete</a></td>
</tr>
{% endfor %}
</table>
{% else %}
<b>There is no data in project land!</b>
{% endif %}
{% endblock %}

1
templates/test.html Normal file
View File

@ -0,0 +1 @@
YOU SUCK1

66
templates/time_view.html Normal file
View File

@ -0,0 +1,66 @@
{% extends "layout.html" %}
{% block body %}
<h1>Time Entries</h1>
Filter:
<form action="{{ url_for('show_time') }}" method="post">
<input type="date" name="start_date" id="datePicker" class="datePicker">
<input type="date" name="end_date" id="datePicker" class="datePicker">
<button type="submit">Filter</button>
<br>
Start: {{ dates[0] }}<br>
End: {{ dates[1] }}
</form>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<ul class=flashes>
{% for category, message in messages %}
<li class="{{ category }}">{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% if time_entries %}
<table class="table table-condensed table-bordered table-striped">
<tr>
<th>ID</th>
<th>Name</th>
<th>Start Date</th>
<th>Start Time</th>
<th>End Date</th>
<th>End Time</th>
<th>Total</th>
</tr>
{% for time in time_entries %}
<tr>
<td>{{ time.employee_id }}</td>
<td>
{% for employee in employees %}
{% if employee.id == time.employee_id %}
{{employee.first_name}} {{employee.last_name}}
{% endif %}
{% endfor %}
</td>
<td>{{ time.date_start }}</td>
<td>{{ time.start }}</td>
<td>{{ time.date_end }}</td>
<td>{{ time.end }}</td>
<td>{{ time.total }}</td>
</tr>
{% endfor %}
<!--Total Time-->
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<th>Total</th>
<td>{{ total[0] }}:{{ total[1] }}:00</td>
</tr>
</table>
{% else %}
<b>There is no data in time entry land!</b>
{% endif %}
{% endblock %}