-
Notifications
You must be signed in to change notification settings - Fork 39
#P08: Resources page setup #77
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
Merged
stefdworschak
merged 8 commits into
Code-Institute-Community:master
from
irinatu17:resources_setup
Oct 23, 2020
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bfb64ce
Resources app created
irinatu17 730908c
Basic resources setup:urls, view, template structure added
irinatu17 ef47b9c
Created Resource model, further migrations applied
irinatu17 68b8a0a
Complited resources page:layout and styling added,view updated
irinatu17 95be57b
Resolved conflict with upstream master in urls.py
irinatu17 418047d
#P08: automated tests for models added
irinatu17 83ed95a
P08: resources fixture added
irinatu17 b377bec
P08: minor changes-description field added,tests updated,minor stylin…
irinatu17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class ResourcesConfig(AppConfig): | ||
| name = 'resources' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." | ||
| } | ||
| } | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()), | ||
| ], | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| description = models.TextField(max_length=400, default="") | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.