Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.8]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,5 @@ docs/public/
backup/rclone.*
webserver/certs/*
!webserver/certs/.gitkeep

psql12.dump.sql
205 changes: 205 additions & 0 deletions src/log/templates/log/list_view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{% extends 'common/base.html' %} {% block styles %}
<style>
.projects {
background-color: white;
padding-top: 2em;
margin: auto;
border-radius: 2rem;
padding-bottom: 3em;
margin-bottom: 5em;
}

.project .row {
margin: 0;
padding: 15px 0;
margin-bottom: 15px;
border-radius: 1em;
padding-left: 10px;
}

.project div[class*='col-'] {
border-right: 1px solid #eee
}

.project .text h3 {
margin-bottom: 0;
color: #555
}

.project .text small {
color: #aaa;
font-size: 0.75em
}

.project .project-date span {
font-size: 0.9em;
color: #999
}

.project .image {
max-width: 100px;
min-width: 100px;
height: 100px;
margin-right: 15px;
margin-top: 10px;
margin-bottom: 10px;
border-radius: 1em;
}

.project .time,
.project .comments,
.project .time i,
.project .comments i,
.project .card {
margin-bottom: 0
}

@media (max-width: 991px) {
.project .right-col {
margin-top: 20px;
margin-left: 65px
}
}

.has-shadow {
-webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1), -1px 0 2px rgba(0, 0, 0, 0.05);
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.1), -1px 0 2px rgba(0, 0, 0, 0.05);
}

.has-shadow:hover {
-webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1), -1px 0 2px rgba(0, 0, 0, 0.05);
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.1), -1px 0 2px rgba(0, 0, 0, 0.05);
}

.bg-white {
background: #fff !important;
}

.bg-red {
background: #ff7676 !important;
color: #fff
}

.bg-red:hover {
color: #fff
}

.project-text-content {
/* padding: 5%; */
padding-right: 1em;
padding-left: 10px;
}

.project-wrapper {
color: black;
}
</style>

{% endblock styles %} {% block content %}

{% if error %}
<div class="container">
<div class="alert alert-danger" role="alert">
{{error}}
</div>
</div>
{% endif %}

{% if not error %}
<div class="container projects">
<div class="container ">
<div class="row justify-content-between">
<div class="col-4">
<h1> {{ page_title }} </h1>
</div>
{% if loglistpage %}
<select class="btn btn-outline-info btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false" id="projects" onchange="project(this.value)">
<div class="dropdown-menu">
<option class="dropdown-item" value="all">All projects</option>
{% for project in projects %}
<option value="{{project.id}}">{{ project.title }}</option>
{% endfor %}
</div>
</select>
{% endif %}
{% if userpage %}

<div class="col-4 " style="margin: 0px;">
<a class="btn btn-primary fa-pull-right" href="{% url 'log-create' %}">New Log</a>

</div>
{% endif %}


</div>
<div class="row">
<div class="col">
<hr>

</div>
</div>
{% if not logs %}
<div class="project">
<h6>{{ welcomemessage }}</h6>
</div> {% endif %}
{% for log in logs %}
<!-- Project-->
<div class="project">

<div class="row bg-white has-shadow">

<div class="left-col col-lg-9 d-flex align-items-center justify-content-between">
<div class="project-title d-flex align-items-center">
<div class="image has-shadow rounded"><img src="{{log.user.profile.image.url}}" alt="..."
class="img-fluid"></div>
<div class="text project-text-content">
<a href="{% url 'log-detail' log.id %}">
<h3 class="h4">{{ log.title }}</h3>
</a>
<small>{{ log.short_description }}</small>
</div>
</div>
</div>
<div class="right-col col-lg-3 align-items-end justify-content-around">
<div class="project-wrapper mb-2">
{% if log.project %} Project: {{ log.project }} {% else %} Personal Log {% endif %}
</div>
<div class="form-group ">
Author: {{ log.user.username }}
</div>
<div class="project-date"><span class="hidden-sm-down">{{ log.date_modified }}</span></div>

</div>
</div>
</div>

{% endfor %}

{% if loglistpage %}
<br>
<hr><br>
{% include 'common/pagination.html' with page=logs %}
{% endif %}

</div>
<!-- Project-->

</div>
{% endif %}
{% endblock content %} {% block scripts %}

{% if not error %}
{% if not personal %}
<script>
document.getElementById("projects").value = "{{selected}}";
function project(slug) {
window.location.replace(`/logs/${slug}`);
}
</script>
{% endif %}

<script>
</script>
{% endif %}
{% endblock scripts %}
2 changes: 1 addition & 1 deletion src/log/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
path('log/<uuid:pk>/edit',
views.logEditView, name='log-edit'),
path('log/', views.logListView, name='log-list'),
path('logs/all', views.allLogsView, name='logs-all'),
path('logs/<str:id>', views.allLogsView, name='logs-all'),
path('log/uploadfile', views.fileUploadHandler, name='file-upload'),
path('log/delete', views.logDeleteView, name='log-delete'),
path('log/bin', views.recBinView, name='log-bin'),
Expand Down
71 changes: 56 additions & 15 deletions src/log/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from django.db.models import Q
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
import json
import re
import os
from django.views.generic import (
Expand All @@ -23,6 +24,7 @@
DeleteView,
TemplateView
)
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.shortcuts import redirect
from django.urls import reverse, reverse_lazy
from django.contrib.auth.models import User
Expand Down Expand Up @@ -78,7 +80,7 @@ class LoggerUpdateView(LoginRequiredMixin, UserPassesTestMixin, UpdateView):

class LoggerListView(LoginRequiredMixin, UserPassesTestMixin, ListView):
"""
Display All Logs from User
Display All Logs from User
"""
model = Logger
template_name = 'log/logger_list.html'
Expand All @@ -96,14 +98,10 @@ class LoggerUnPublish(LoginRequiredMixin, UserPassesTestMixin, TemplateView):
def logCreateView(request):

user_teams = request.user.team_set.all()
project_list = []

for team in user_teams:
project_list.append(team.project)


# pass in this list
context = {
"projects": project_list,
"teams": user_teams,
"files": LogFile.objects.filter(user=request.user),

}
Expand Down Expand Up @@ -275,23 +273,66 @@ def logListView(request):
"logs": Logger.objects.filter(user=request.user, project=None).filter(published=True).order_by('-date_created'),
"page_title": "Personal logs:",
"userpage": True,
"personal": True,
"welcomemessage": 'Create your first log by clicking on the "New Log" Button !',
}
return render(request, 'log/list_view.html', context)


@login_required
def allLogsView(request):
def allLogsView(request, id):
teams = request.user.team_set.all()
projects = Project.objects.filter(team__in=teams)
logs = Logger.objects.filter(project__in=projects).filter(published=True)

context = {
"logs": logs.order_by('-date_created'),
"page_title": "Project logs:",
"userpage": True,
"welcomemessage": 'Create your first log by clicking on the "New Log" Button !',
}
if id == 'all':
logs_list = Logger.objects.filter(
project__in=projects).filter(published=True).order_by('-date_created')
context = {
"projects": projects.order_by('title'),
"page_title": "Project logs:",
"userpage": True,
"loglistpage": True,
"selected": 'all',
"welcomemessage": 'Create your first log by clicking on the "New Log" Button !',
}
else:
try:
id = UUID(id, version=4)
except ValueError:
context = {
"error": "Invalid project ID.",
}
return render(request, 'log/list_view.html', context)
project = projects.filter(id=id)
if not project.exists():
context = {
"error": "You are not a part of this project.",
}
return render(request, 'log/list_view.html', context)

logs_list = Logger.objects.filter(
project__in=project).filter(published=True).order_by('-date_created')
context = {
"projects": projects.order_by('title'),
"page_title": "Project logs:",
"userpage": True,
"loglistpage": True,
"selected": project[0].id,
"welcomemessage": 'Create your first log by clicking on the "New Log" Button !',
}

paginator = Paginator(logs_list, 10)
page = request.GET.get('page')
try:
logs = paginator.page(page)
except PageNotAnInteger:
logs = paginator.page(1)
except EmptyPage:
logs = paginator.page(paginator.num_pages)

context["logs"] = logs
context["page"] = page

return render(request, 'log/list_view.html', context)


Expand Down
1 change: 0 additions & 1 deletion src/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def projectListView(request):
# add member and log count
project.nooflogs = Logger.objects.filter(project=project).count()
project.noofteams = project.team_set.all().count()
print(project.noofteams, project.nooflogs)

# Limit description length
if len(project.description) > 130:
Expand Down
10 changes: 5 additions & 5 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
amqp==1.4.9
anyjson==0.3.3
asgiref==3.2.7
asgiref==3.2.10
astroid==2.4.2
autopep8==1.5.2
backcall==0.2.0
Expand All @@ -9,7 +9,7 @@ celery==3.1.26.post2
certifi==2020.11.8
cffi==1.14.0
decorator==4.4.2
Django==3.0.7
Django==3.1.6
django-appconf==1.0.4
django-celery==3.3.1
django-contrib-comments==1.9.2
Expand All @@ -18,7 +18,7 @@ django-debug-toolbar==2.2
django-extensions==2.2.9
django-formtools==2.2
django-imagekit==4.0.2
djangorestframework==3.11.1
djangorestframework==3.11.2
djecrety==1.0.13
ipython==7.15.0
ipython-genutils==0.2.0
Expand All @@ -31,7 +31,7 @@ parso==0.7.0
pexpect==4.8.0
pickleshare==0.7.5
pilkit==2.0
Pillow==7.1.2
Pillow==8.1.1
prompt-toolkit==3.0.5
ptyprocess==0.6.0
pycodestyle==2.6.0
Expand All @@ -46,6 +46,6 @@ six==1.15.0
sqlparse==0.3.1
toml==0.10.1
traitlets==4.3.3
urllib3==1.26.2
urllib3==1.26.3
wcwidth==0.2.4
wrapt==1.12.1
Loading