Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e6dd2fe
#P04 Started Hackathon app
Ri-Dearg Oct 14, 2020
ce1d431
Merge branch 'master' into p04
Ri-Dearg Oct 15, 2020
cb69915
Added URLs and Installed App.
Ri-Dearg Oct 15, 2020
4f55cc6
Created "Hackathon" Model
Ri-Dearg Oct 15, 2020
2949910
Created Hack Award Category Model
Ri-Dearg Oct 15, 2020
ce56f46
HackTeam model created
Ri-Dearg Oct 15, 2020
5c004f0
Created HackProject model
Ri-Dearg Oct 15, 2020
277d7c9
Created HackProjectScoreModel
Ri-Dearg Oct 15, 2020
6ed572d
Created HackProjectScoreCategory Model
Ri-Dearg Oct 15, 2020
a2f75c1
Added Foreign Key Fields
Ri-Dearg Oct 15, 2020
2015a80
Merge branch 'master' into m05
Ri-Dearg Oct 15, 2020
2b741b2
Commented on ForeignKey fields
Ri-Dearg Oct 16, 2020
b7376ee
Added URLFields
Ri-Dearg Oct 16, 2020
45a288b
Added URLFields
Ri-Dearg Oct 16, 2020
46064fd
Merge branch 'm05' of https://github.com/Ri-Dearg/ci-hackathon-app in…
Ri-Dearg Oct 16, 2020
591169f
Delete settings.json
Ri-Dearg Oct 16, 2020
07afd39
Pull Request review changes made.
Ri-Dearg Oct 16, 2020
f210249
Merge branch 'm05' of https://github.com/Ri-Dearg/ci-hackathon-app in…
Ri-Dearg Oct 16, 2020
c85533b
Updated gitignore to ignore settings.json
Ri-Dearg Oct 16, 2020
88c7540
Added last extra line on file
Ri-Dearg Oct 16, 2020
8131a73
Removed unecessary import and quotes.
Ri-Dearg Oct 16, 2020
352c80e
Corrected Typo and added migrations.
Ri-Dearg Oct 16, 2020
1195184
Updated str method on HackProjectScoreCategory to remove "score"
Ri-Dearg Oct 16, 2020
bdefd17
Updated str method on HackProjectScoreCategory to remove "score"
Ri-Dearg Oct 16, 2020
69603b2
Merge branch 'm05' of https://github.com/Ri-Dearg/ci-hackathon-app in…
Ri-Dearg Oct 16, 2020
875cc06
Test setUp method added and functional
Ri-Dearg Oct 16, 2020
9cdbfcf
Tests written for str method on models.
Ri-Dearg Oct 16, 2020
f09fae8
Updated Related names in models
Ri-Dearg Oct 17, 2020
b1f3100
Updated .gitignore.
Ri-Dearg Oct 17, 2020
3899109
Merge branch 'master' into m05
Ri-Dearg Oct 17, 2020
f3ce532
Added migration file.
Ri-Dearg Oct 17, 2020
26fa31b
Merge branch 'm05' of https://github.com/Ri-Dearg/ci-hackathon-app in…
Ri-Dearg Oct 17, 2020
0bef661
Created HackathonListView
Ri-Dearg Oct 17, 2020
377c4da
Tests for Hackathon app views added.
Ri-Dearg Oct 17, 2020
9d9cbb8
Added templates for the Hackathon list.
Ri-Dearg Oct 17, 2020
5461820
.card-title added to style.css
Ri-Dearg Oct 17, 2020
4c51998
Added basic pagination.
Ri-Dearg Oct 17, 2020
bbee150
Paginator now an include for modularity
Ri-Dearg Oct 17, 2020
0b015ac
Styled the Paginator and cards.
Ri-Dearg Oct 17, 2020
be2d121
Merge with master
Ri-Dearg Oct 17, 2020
9152d93
Tests Added for queryset. Listview cleaned up.
Ri-Dearg Oct 17, 2020
1d9c07c
Added "Hackathon" dropdown to navbar as draft.
Ri-Dearg Oct 17, 2020
0478830
Format changes for HTML5 Verification.
Ri-Dearg Oct 17, 2020
880a09d
Updated style changes for custom colors on text.
Ri-Dearg Oct 17, 2020
a965fbc
Fixed validation errors I introduced in navbar
Ri-Dearg Oct 17, 2020
5d99ae7
Formatted spaces in style.css
Ri-Dearg Oct 18, 2020
05241eb
Removed unnecessary ".save()" from tests.
Ri-Dearg Oct 18, 2020
99bab42
Removed unnecessary indentation.
Ri-Dearg Oct 18, 2020
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
19 changes: 19 additions & 0 deletions hackathon/templates/hackathon/hackathon_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "base.html" %}
{% load static %}
{% block content %}
<section class="h-100">
{% if page_obj %}
<h2 class="p-orange text-center mb-4">Hackathons</h2>
{% for hackathon in page_obj %}
{% include 'hackathon/includes/hackathon_card.html' %}
<hr>
{% endfor %}
{% else %}
<h2 class="text-center">There aren't any Hackathons at the moment!</h2>
{% endif %}
<!-- Pagination using Django's paginator. Options are disabled or hidden if unavailable. -->
<nav aria-label="Hackathon Page Navigation">
{% include 'hackathon/includes/paginator.html' %}
</nav>
</section>
{% endblock %}
11 changes: 11 additions & 0 deletions hackathon/templates/hackathon/includes/hackathon_card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<article class="card shadow">
<div class="card-body">
<h5 class="p-orange card-title">{{ hackathon.display_name }}</h5>
<h6 class="card-subtitle mb-2 text-muted">{{ hackathon.start_date }} - {{ hackathon.end_date }}</h6>
<p class="card-text">{{ hackathon.description }}</p>
{% if hackathon.organiser %}
<p>Organiser: <a href="#" class="p-blue card-link">{{ hackathon.organiser }}</a></p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need to show the organiser, but let's leave it for the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought it could be handy if people had public-facing profiles. It might not be so useful otherwise.

{% endif %}
<a href="#" class="btn btn-ci">Read More</a>
</div>
</article>
18 changes: 18 additions & 0 deletions hackathon/templates/hackathon/includes/paginator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item"><a class="page-link" href="?page=1" aria-label="First">
<span aria-hidden="true">&laquo;</span></a>
</li>
<li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}">{{ page_obj.previous_page_number }}</a></li>
{% else %}
<li class="page-item disabled"><a class="page-link" href="#" tabindex="-1" aria-disabled="true">&laquo;</a></li>
{% endif %}
<li class="page-item active" aria-current="page"><a class="page-link" href="#">{{ page_obj.number }}<span class="sr-only">(current)</span></a></li>
{% if page_obj.has_next %}
<li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}">{{ page_obj.next_page_number }}</a></li>
<li class="page-item"><a class="page-link" href="?page={{ page_obj.paginator.num_pages }}" aria-label="Last">
<span aria-hidden="true">&raquo;</span></a></li>
{% else %}
<li class="page-item disabled"><a class="page-link" href="#" tabindex="-1" aria-disabled="true">&raquo;</a></li>
{% endif %}
</ul>
12 changes: 3 additions & 9 deletions hackathon/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,43 @@ class HackathonTests(TestCase):
def setUp(self):
"""Sets up the models for testing"""
user = User.objects.create(username="testuser")
user.save()

hackathon = Hackathon.objects.create(
created_by=user,
display_name="hacktest",
description="lorem ipsum",
start_date=f'{timezone.now()}',
end_date=f'{timezone.now()}')
hackathon.save()

team = HackTeam.objects.create(
created_by=user,
display_name="testteam",
hackathon=hackathon)
team.save()
team.participants.set([user])

award_category = HackAwardCategory.objects.create(
HackAwardCategory.objects.create(
created_by=user,
display_name="testaward",
description="lorem ipsum",
hackathon=hackathon)
award_category.save()

project = HackProject.objects.create(
created_by=user,
display_name="testproject",
description="lorem ipsum",
github_link="https://www.test.com/",
collab_link="https://www.test.com/")
project.save()

score_category = HackProjectScoreCategory.objects.create(
created_by=user,
category="testcategory")
score_category.save()

score = HackProjectScore.objects.create(
HackProjectScore.objects.create(
created_by=user,
judge=user,
project=project,
score=1,
hack_project_score_category=score_category)
score.save()

def test_hackathon_str(self):
"""Tests the string method on the hackathon."""
Expand Down
36 changes: 36 additions & 0 deletions hackathon/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from django.test import TestCase
from django.contrib.auth.models import User
from django.utils import timezone

from hackathon.models import Hackathon


class TestHackathonViews(TestCase):
"""Tests views for the Hackathon app."""

def setUp(self):
"""Sets up the models for testing"""
user = User.objects.create(username="testuser")
Hackathon.objects.create(
created_by=user,
display_name="hacktest",
description="lorem ipsum",
start_date=f'{timezone.now()}',
end_date=f'{timezone.now()}')

def test_render_hackathon_list(self):
"""Tests the correct rendering of the hackathon list page,
including contexts."""

response = self.client.get('/hackathon/')

# Confirms the correct template, context items and queryset
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'hackathon/hackathon_list.html')
self.assertTemplateUsed(response,
'hackathon/includes/hackathon_card.html')
self.assertTemplateUsed(response, 'hackathon/includes/paginator.html')
self.assertTrue(response.context['page_obj'])
self.assertQuerysetEqual(response.context['page_obj'],
Hackathon.objects.all().order_by('-created'),
transform=lambda x: x)
4 changes: 3 additions & 1 deletion hackathon/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.urls import path

urlpatterns = [
from .views import HackathonListView

urlpatterns = [
path('', HackathonListView.as_view(), name="hackathon-list")
]
11 changes: 9 additions & 2 deletions hackathon/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.shortcuts import render
from django.views.generic import ListView

# Create your views here.
from .models import Hackathon


class HackathonListView(ListView):
"""Renders a page with a list of Hackathons."""
model = Hackathon
ordering = ['-created']
paginate_by = 8
28 changes: 28 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,31 @@ footer {
color: var(--s-grey);
background-color: var(--p-grey);
}

/* TEXT */
.p-orange {
color: var(--p-orange);
}

.p-blue {
color: var(--p-blue);
}

/* CARDS */
.card-link:hover {
color: rgba(0, 0, 0, .7);
}

.card-title {
font-family: Rubik, sans-serif;
}

/* PAGINATION */
.page-item .page-link {
color: var(--p-orange);
}

.page-item.active .page-link {
background-color: var(--p-orange);
border-color: var(--p-orange);
}
11 changes: 11 additions & 0 deletions templates/includes/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
<li class="nav-item">
<a class="nav-link" href="{% url 'home' %}">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarHackathons" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Hackathons
</a>
<div class="dropdown-menu" aria-labelledby="navbarHackathons">
<a class="dropdown-item" href="{% url 'hackathon:hackathon-list' %}">Events</a>
<a class="dropdown-item" href="#">Winning Projects</a>
<a class="dropdown-item" href="#">Awards</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarResources" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Expand Down