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

Bug app #10

Merged
merged 62 commits into from
Mar 1, 2024
Merged
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c790114
added the models for the bug app
ikeadeoyin Jan 25, 2024
9bc8a77
updated CapX settings with media directory
ikeadeoyin Feb 7, 2024
ce4b5af
updated the null and blank options on bug_type and status to True
ikeadeoyin Feb 7, 2024
d5b0989
added the url for the bugs app
ikeadeoyin Feb 7, 2024
9fbc7c8
updated the admin view to show the bug and attachments together
ikeadeoyin Feb 7, 2024
b465c91
views for the bug app
ikeadeoyin Feb 7, 2024
2eca1e9
form the bugs app
ikeadeoyin Feb 7, 2024
f1fd482
url for the bugs app
ikeadeoyin Feb 7, 2024
465aea9
html templates for the bugs app
ikeadeoyin Feb 7, 2024
a83bae5
migrations
ikeadeoyin Feb 7, 2024
8a774ba
updated the bug list views
ikeadeoyin Feb 13, 2024
201b663
Merge branch 'main' into bug-app
albertoleoncio Feb 13, 2024
6863749
made changes
ikeadeoyin Feb 13, 2024
0ffa325
add the media folder to gitignore
ikeadeoyin Feb 13, 2024
c9be2c5
Fixing rebase
albertoleoncio Feb 13, 2024
ed19d88
+some styles at register_bug.html
albertoleoncio Feb 13, 2024
d9777ba
updated the feedback tab link
ikeadeoyin Feb 20, 2024
45f5034
added links to update an delete a bug
ikeadeoyin Feb 20, 2024
b003917
added urls to update and delete a bug
ikeadeoyin Feb 20, 2024
c987a66
added the flash message
ikeadeoyin Feb 20, 2024
0f94080
added links to update and delete a bug
ikeadeoyin Feb 20, 2024
befdb5a
template to update a bug
ikeadeoyin Feb 20, 2024
624cfe8
added the views to update and delete a bug
ikeadeoyin Feb 20, 2024
d84d239
Merge branch 'bug-app' of https://github.com/WikiMovimentoBrasil/capx…
ikeadeoyin Feb 20, 2024
ae612eb
Merge branch 'main' into bug-app
albertoleoncio Feb 21, 2024
dff4578
added link to add a bug
ikeadeoyin Feb 21, 2024
d579ea8
views documentation
ikeadeoyin Feb 23, 2024
c46ccb8
tests for the bug app
ikeadeoyin Feb 26, 2024
0e71f8c
added test for the bug app views
ikeadeoyin Feb 29, 2024
3d9b600
Merge branch 'main' into bug-app
albertoleoncio Feb 29, 2024
4a225a3
made changes to the test
ikeadeoyin Feb 29, 2024
f479363
added bug_form_url
ikeadeoyin Feb 29, 2024
2ddfa2f
made changes
ikeadeoyin Feb 29, 2024
bbd3e0a
made changes
ikeadeoyin Feb 29, 2024
ea08312
made changes
ikeadeoyin Feb 29, 2024
eeb9868
made changes
ikeadeoyin Feb 29, 2024
161be70
made changes
ikeadeoyin Feb 29, 2024
89307ac
made changes
ikeadeoyin Feb 29, 2024
d71c1f6
made changes
ikeadeoyin Feb 29, 2024
fea479c
made changes
ikeadeoyin Feb 29, 2024
5a92a50
made changes
ikeadeoyin Feb 29, 2024
2c62c0f
made changes
ikeadeoyin Feb 29, 2024
40f6cf9
made changes
ikeadeoyin Feb 29, 2024
2094db3
made changes
ikeadeoyin Feb 29, 2024
995d194
added tests
ikeadeoyin Feb 29, 2024
b71337d
made changes
ikeadeoyin Feb 29, 2024
80bfeb1
made changes
ikeadeoyin Feb 29, 2024
8d5ef7b
made changes
ikeadeoyin Feb 29, 2024
7a2cfc3
made changes
ikeadeoyin Feb 29, 2024
8bd9270
made changes
ikeadeoyin Feb 29, 2024
18b14d2
made changes
ikeadeoyin Feb 29, 2024
5dd6403
made changes
ikeadeoyin Feb 29, 2024
be7f4dd
made changes
ikeadeoyin Feb 29, 2024
020c241
made changes
ikeadeoyin Feb 29, 2024
1c32741
made changes
ikeadeoyin Feb 29, 2024
ab7b0c1
made changes
ikeadeoyin Feb 29, 2024
4d3135c
made changes
ikeadeoyin Feb 29, 2024
487db74
made changes
ikeadeoyin Feb 29, 2024
4228ba1
made changes
ikeadeoyin Feb 29, 2024
3a495e2
made changes
ikeadeoyin Feb 29, 2024
10eb9c6
made changes
ikeadeoyin Feb 29, 2024
0114897
made changes
ikeadeoyin Mar 1, 2024
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
Prev Previous commit
Next Next commit
views documentation
  • Loading branch information
ikeadeoyin committed Feb 23, 2024
commit d579ea890a3d4c9cb0be1a36cccc6284cdd65dce
44 changes: 34 additions & 10 deletions bugs/views.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
from django.shortcuts import render, redirect, reverse, get_object_or_404
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from .forms import BugForm

from django.views.generic import ListView, CreateView # new
from django.urls import reverse_lazy # new

# from .forms import BugForm # new
from .forms import BugForm
from .models import Bug, Attachment
# Create your views here.


# bugs homepage
@login_required
def homepage(request):
# context = {}
# return render(request, "bugs/index.html", context)
"""
View to display the bugs reporting homepage
:param request:
:return: returns all bugs and a link to submit a new bug report
"""
bugs = Bug.objects.filter(user=request.user) # Get all bugs from the database
return render(request, 'bugs/bug_list.html', {'bugs': bugs})


@login_required()
def bug_form(request):
"""
View to submit a new bug report
:param request:
:return: returns all bugs including the new bug report
"""
if request.method == 'POST':
form = BugForm(request.POST, request.FILES)
if form.is_valid():
Expand Down Expand Up @@ -51,6 +52,11 @@ def bug_form(request):

@login_required()
def bug_list(request):
"""
View to display all the bugs created by the authenticated user
:param request:
:return: list of all bugs created by the authenticated user
"""
if request.user.is_superuser:
bugs = Bug.objects.all() # Retrieves all bugs for superuser
else:
Expand All @@ -60,13 +66,25 @@ def bug_list(request):

@login_required()
def bug_detail(request, bug_id):
"""
View to display the details of a bug by id
:param request:bug i
:param bug_id:
:return: details about the bug
"""
bug = get_object_or_404(Bug, pk=bug_id) # Fetch the bug or return a 404
attachments = bug.attachments.all() # Retrieve all related attachments
return render(request, 'bugs/bug_detail.html', {'bug': bug, 'attachments': attachments})


@login_required()
def update_bug(request, bug_id):
"""
View to update a bug by id and its attachments
:param request:
:param bug_id: id of the bug to be updated
:return: details about the updated bug
"""
bug = get_object_or_404(Bug, pk=bug_id)

if not (request.user == bug.user or request.user.is_superuser):
Expand Down Expand Up @@ -98,6 +116,12 @@ def update_bug(request, bug_id):
@login_required()
@permission_required('bugs.delete_bug')
def delete_bug(request, bug_id):
"""
Delete an existing bug by id
:param request:
:param bug_id:
:return: returns the list of all bugs after deleting the specified bug
"""
bug = get_object_or_404(Bug, pk=bug_id)
bug.delete()
messages.success(request, 'Bug deleted successfully!')
Expand Down