Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add time logs for sizzle users #2807

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions website/templates/includes/user_sidenav.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
<li>
<a href="{% url 'user_profile' slug=user.username %}"><i class="lnr lnr-user"></i><span>Profile</span></a>
</li>
<li>
<a href="{% url 'time_logs' %}"><i class="lnr lnr-clock"></i><span>Time Logs</span></a>
</li>
</ul>
</div>
38 changes: 38 additions & 0 deletions website/templates/time_logs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% extends "base.html" %}
{% load static %}

{% block content %}
<div class="container">
<h1>Time Logs</h1>
<form method="post" action="{% url 'start_time_log' %}">
{% csrf_token %}
<div class="form-group">
<label for="github_issue_url">GitHub Issue URL:</label>
<input type="url" class="form-control" id="github_issue_url" name="github_issue_url" required>
</div>
<button type="submit" class="btn btn-primary">Start Time Log</button>
</form>

<h2>Existing Time Logs</h2>
<table class="table">
<thead>
<tr>
<th>Start Time</th>
<th>End Time</th>
<th>Duration</th>
<th>GitHub Issue URL</th>
</tr>
</thead>
<tbody>
{% for log in time_logs %}
<tr>
<td>{{ log.start_time }}</td>
<td>{{ log.end_time }}</td>
<td>{{ log.duration }}</td>
<td><a href="{{ log.github_issue_url }}" target="_blank">{{ log.github_issue_url }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock content %}
7 changes: 7 additions & 0 deletions website/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from .views import TimeLogListView, start_time_log

urlpatterns = [
path('time-logs/', TimeLogListView.as_view(), name='time_logs'),
path('start-time-log/', start_time_log, name='start_time_log'),
]
18 changes: 18 additions & 0 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2507,3 +2507,21 @@ def TimeLogListAPIView(request):

def sizzle_docs(request):
return render(request, "sizzle/sizzle_docs.html")


@login_required
def TimeLogListView(request):
time_logs = TimeLog.objects.filter(user=request.user).order_by("-start_time")
return render(request, "time_logs.html", {"time_logs": time_logs})


@login_required
def start_time_log(request):
if request.method == "POST":
github_issue_url = request.POST.get("github_issue_url")
if github_issue_url:
TimeLog.objects.create(user=request.user, start_time=now(), github_issue_url=github_issue_url)
messages.success(request, "Time log started successfully.")
else:
messages.error(request, "GitHub Issue URL is required.")
return redirect("time_logs")
Loading