Skip to content

Commit

Permalink
Merge pull request #1 from ruben69695/project-tech
Browse files Browse the repository at this point in the history
Added new feature for projects in which they can have different technologies related to them
  • Loading branch information
ruben69695 authored Jun 21, 2022
2 parents 70ff796 + 2597ba3 commit 72bcee4
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 25 deletions.
8 changes: 7 additions & 1 deletion core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ class ContactMessageAdmin(admin.ModelAdmin):
readonly_fields = ()

class TechnologyAdmin(admin.ModelAdmin):
readonly_fields = ('name', 'created')
readonly_fields = ['created']

def get_readonly_fields(self, request, obj=None):
defaults = super().get_readonly_fields(request, obj=obj)
if obj: # if we are updating an object
defaults = ['name'] + defaults
return defaults

admin.site.register(ContactMessage, ContactMessageAdmin)
admin.site.register(Technology, TechnologyAdmin)
24 changes: 14 additions & 10 deletions core/static/core/css/portfolio.css
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
.project {
background-color: #16192A;
border: none;
margin-bottom: 3vh;
width: 24rem;
background: none;
background-color: #16192A;
}

#container {
margin-top: 5vh;
margin-bottom: 5vh;
}

.card-project-body {
display: flex;
justify-content: space-between;
align-items: stretch;
flex-direction: column;
}

.pimage {
border-radius: 25%;
}

.footer {
border: none;
}

.plink {
width: 100%;
}

.tech {
color: #0F111D;
}
19 changes: 19 additions & 0 deletions portfolio/migrations/0003_project_technologies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.0.4 on 2022-06-20 20:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0003_remove_technology_updated'),
('portfolio', '0002_auto_20190116_0701'),
]

operations = [
migrations.AddField(
model_name='project',
name='technologies',
field=models.ManyToManyField(to='core.technology', verbose_name='Technologies'),
),
]
4 changes: 3 additions & 1 deletion portfolio/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from django.db import models
from core.models import Technology

# Create your models here.
class Project(models.Model):
title = models.CharField(max_length=200, verbose_name="Título")
description = models.TextField(verbose_name="Descripción")
image = models.ImageField(verbose_name="Imagen", upload_to="projects")
url = models.URLField(max_length=200, verbose_name="URL del Proyecto", default="#")
technologies = models.ManyToManyField(Technology, verbose_name="Technologies")
created = models.DateTimeField(auto_now_add=True, verbose_name="Fecha de creación")
updated = models.DateTimeField(auto_now=True, verbose_name="Fecha de edición")

Expand All @@ -15,4 +17,4 @@ class Meta:
ordering = ["-created"]

def __str__(self):
return self.title
return self.title
26 changes: 14 additions & 12 deletions portfolio/templates/portfolio/portfolio.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@
{% endblock customcss %}
{% block content %}
<div id="container" class="container">
<div class="row d-flex flex-row">
<div class="row">
{% for project in projects %}
<div class="col d-flex">
<div class="card project">
<img class="pimage card-img-top p-5"
src="{{ project.image.url }}"
alt="img_{{ project.title }}"
width="auto"
height="auto"/>
<div class="card-body card-project-body">
<h5 class="card-title">{{ project.title }}</h5>
<p class="card-text">{{ project.description }}</p>
<a href="{{ project.url }}" class="btn btn-primary">View project</a>
<div class="col col-project m-3">
<div class="card project h-100">
<div class="card-body">
<h5 class="card-title">{{ project.title }}</h5>
<div class="card-text my-3">
{% for tech in project.technologies.all %}
<span class="badge tech text-bg-warning">{{ tech.name }}</span>
{% endfor %}
</div>
<p class="card-text">{{ project.description }}</p>
</div>
<div class="card-footer footer my-3">
<a href="{{ project.url }}" class="btn btn-primary plink">View project</a>
</div>
</div>
</div>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion portfolio/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# Create your views here.
def portfolio(request):
projects = Project.objects.all()
return render(request, "portfolio/portfolio.html", {'projects': projects})
return render(request, "portfolio/portfolio.html", {'projects': projects})

0 comments on commit 72bcee4

Please sign in to comment.