Skip to content
Merged
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
1 change: 1 addition & 0 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"home",
'accounts',
"profiles",
"resources",
"crispy_forms",
# M05 App "Hackathon" added
"hackathon",
Expand Down
1 change: 1 addition & 0 deletions main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
path("admin/", admin.site.urls),
path("accounts/", include("allauth.urls")),
path("profile/", include("profiles.urls")),
path("resources/", include("resources.urls")),
path("hackathon/", include(("hackathon.urls", "hackathon"),
namespace='hackathon')),
]
Empty file added resources/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions resources/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib import admin
from resources.models import Resource


class ResourceAdmin(admin.ModelAdmin):
list_display = (
'name',
'link',
)


admin.site.register(Resource, ResourceAdmin)
5 changes: 5 additions & 0 deletions resources/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ResourcesConfig(AppConfig):
name = 'resources'
94 changes: 94 additions & 0 deletions resources/fixtures/resources.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
[
{
"model": "resources.resource",
"pk": 1,
"fields": {
"name": "Gitpod - Code Institute full template",
"link": "https://github.com/Code-Institute-Org/gitpod-full-template",
"description": "Full workspace template for GitPod. Provides extensions and tools for CI students."
}
},
{
"model": "resources.resource",
"pk": 2,
"fields": {
"name": "GitHub 'Projects'",
"link": "https://www.youtube.com/watch?v=C6MGKHkNtxU&t=0s",
"description": "Projects are an issue management feature on GitHub which will help you organize Issues, Pull Requests, and notes into a Kanban-style board for better visualization and prioritization of work."
}
},
{
"model": "resources.resource",
"pk": 3,
"fields": {
"name": "The Git Story",
"link": "https://eventyret.github.io/the-git-story/",
"description": "The story of Git. Get to know git commands!"
}
},
{
"model": "resources.resource",
"pk": 4,
"fields": {
"name": "Git Team workflow",
"link": "https://jameschambers.co/git-team-workflow-cheatsheet/",
"description": "Using Git in a team cheatsheet."
}
},
{
"model": "resources.resource",
"pk": 5,
"fields": {
"name": "Forking",
"link": "https://www.youtube.com/watch?v=HbSjyU2vf6Y",
"description": "Git & GitHub Tutorial for Beginners - Forking & Contributing: how to fork a repository to your own GitHub account."

}
},
{
"model": "resources.resource",
"pk": 6,
"fields": {
"name": "Branches",
"link": "https://www.youtube.com/watch?v=QV0kVNvkMxc",
"description": "Git & GitHub Tutorial for Beginners - Branches: introduction to branching and creating new branches to test out new features on."
}
},
{
"model": "resources.resource",
"pk": 7,
"fields": {
"name": "Syncing",
"link": "https://www.youtube.com/watch?v=-zvHQXnBO6c",
"description": "Syncing Your GitHub Fork: what that means and how to do that video-tutorial."
}
},
{
"model": "resources.resource",
"pk": 8,
"fields": {
"name": "Dealing with merge refusal error",
"link": "https://github.bokerqi.topmunity/t/how-to-deal-with-refusing-to-merge-unrelated-histories-error/1372/3#M5000",
"description": "The solution to 'refusing to merge unrelated histories' error."

}
},
{
"model": "resources.resource",
"pk": 9,
"fields": {
"name": "Merge unrelated histories",
"link": "https://www.youtube.com/watch?v=sdNyMmMSU34",
"description": "Check out this video if git won't let you push due to the remote containing work that your local repository doesn't have, despite the fact that the remote repository is a new Git Hub repository and should have no history of its own."
}
},
{
"model": "resources.resource",
"pk": 10,
"fields": {
"name": "Collaborate Issues/Pull Requests",
"link": "https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests",
"description": "GitHub docs: Collaborating with issues and pull requests. Use the GitHub flow to track and discuss changes in issues, then propose and review changes in pull requests."
}
}
]
22 changes: 22 additions & 0 deletions resources/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.1.1 on 2020-10-16 18:56

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Resource',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=254)),
('link', models.URLField()),
],
),
]
18 changes: 18 additions & 0 deletions resources/migrations/0002_resource_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.1 on 2020-10-22 18:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('resources', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='resource',
name='description',
field=models.TextField(blank=True, max_length=800, null=True),
),
]
18 changes: 18 additions & 0 deletions resources/migrations/0003_auto_20201022_2010.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.1 on 2020-10-22 20:10

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('resources', '0002_resource_description'),
]

operations = [
migrations.AlterField(
model_name='resource',
name='description',
field=models.TextField(default='', max_length=400),
),
]
Empty file.
12 changes: 12 additions & 0 deletions resources/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.db import models


class Resource(models.Model):
"""Model representing a Resource that contains the resource's name, description
and an external link to the resource. All the fields are required."""
name = models.CharField(max_length=254)
link = models.URLField(max_length = 200)
Copy link
Member

Choose a reason for hiding this comment

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

Do we only need these keys? I would suggest maybe to add a description as well to give an indication of what you would use each resource for.

description = models.TextField(max_length=400, default="")

def __str__(self):
return self.name
53 changes: 53 additions & 0 deletions resources/templates/resources/resources.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends "base.html" %}
{% load static %}

{% block content %}

<div class="row my-4">
<div class="col-12 text-center mb-3">
<h1>Useful resources and links</h1>
<hr class="divider-orange w-25 mt-4 d">
</div>
<div class="col-12 my-3 d-none d-md-block ">
<!--Resources and Links Table (medium and larger devices)-->
<table class="table table-striped">
<thead>
<tr>
<th scope="col" class="p-orange">Resource & Link</th>
<th scope="col" class="p-orange">Description</th>
</tr>
</thead>
<tbody>
{% for resource in resources %}
<tr>
<th scope="row">
<a href="{{ resource.link }}" target="_blank" rel="noopener" class="text-dark">
<i class="fas fa-link mr-2"></i>
{{ resource.name }}
</a>
</th>
<td class="w-75"> {{ resource.description}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>

<div class="row mb-3">
{% for resource in resources %}
<div class="col-12 d-block d-md-none table border-top pt-2">

<a href="{{ resource.link }}" target="_blank" rel="noopener" class="text-dark font-weight-bold lead">
<i class="fas fa-link mr-2"></i>
{{ resource.name }}
</a>
</div>
<div class="col-12 d-block d-md-none table">
{{ resource.description }}

</div>
{% endfor %}
</div>

{% endblock %}
27 changes: 27 additions & 0 deletions resources/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.test import TestCase
from .models import Resource


class TestResourceModels(TestCase):
"""Tests for Resource models."""

def setUp(self):
"""Sets up the model for testing"""
resource1 = Resource.objects.create(
name = 'Forking',
link = "https://www.youtube.com/watch?v=HbSjyU2vf6Y",
description="lorem ipsum")
resource2 = Resource.objects.create(
name = 'The Git Story',
link = "https://eventyret.github.io/the-git-story/",
description="lorem ipsum")


def test__str_method_returns_name(self):
"""Tests the string method on a resource."""
resource = Resource.objects.create(
name = 'The Git Story',
link = "https://eventyret.github.io/the-git-story/",
description="lorem ipsum")

self.assertEqual(resource.__str__(), "The Git Story")
6 changes: 6 additions & 0 deletions resources/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from . import views

urlpatterns = [
path("", views.resources, name="resources"),
]
11 changes: 11 additions & 0 deletions resources/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.shortcuts import render
from .models import Resource


def resources(request):
""" Display the useful resources and links page. """

template = "resources/resources.html"
resources = Resource.objects.all()

return render(request, template, {'resources': resources})
Loading