Skip to content

Commit

Permalink
Merge pull request #49 from lluminita/add-update-and-detail-views
Browse files Browse the repository at this point in the history
add update and details features
  • Loading branch information
lluminita committed Mar 11, 2016
2 parents 8236e90 + f107e1b commit a8e1dc2
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 28 deletions.
43 changes: 43 additions & 0 deletions projects/templates/projects/project_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% extends "codeeve/index.html" %}

{% block header %}
{% endblock %}

{% block content %}
<div class="content-section-a">

<div class="container">
<div class="row">
<a href="/projects/">Go to list all projects</a>
<a href="update/">Update the project</a>
<div class="col-lg-5 col-sm-6">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">{{ project.title }}</h2>
<p>{{ project.created_at|date:"D d M Y" }}</p>
<div class="glossy-{{ project.difficulty }}">
<p> {{ project.difficulty }}</p>
</div>
<p>{{ project.description}}</p>
{% if project.max_members > project.participants.count %}
<button type="button"> Join!</button>
{% endif %}
</div>

<div class="col-lg-5 col-lg-offset-2 col-sm-6">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
{% if project.image %}
<img src = "{{project.image.url}}">
{% endif %}
</div>
</div>

</div>

</div>

<div>
</div>

{% endblock %}
24 changes: 7 additions & 17 deletions projects/templates/projects/project_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,33 @@
<div class="content-section-a">

<div class="container">
<a href="create/">Create a project</a>
{% for project in object_list %}
<div class="row">
<a href="create/">Create a project</a>
{% for project in object_list %}
<div class="col-lg-5 col-sm-6">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<h2 class="section-heading">{{ project.title }}</h2>
<p>{{ project.created_at|date:"D d M Y" }}</p>
<div
{% if project.difficulty == "beginner" %}
class = glossy-beginner
{% elif project.difficulty == "intermediate" %}
class = glossy-intermediate
{% elif project.difficulty == "advanced" %}
class = glossy-advanced
{% endif %}>
<p> {{ project.difficulty }}</p> </div>
<p>{{ project.description}}</p>
<div class="glossy-{{ project.difficulty }}">
<p> {{ project.difficulty }}</p>
</div>
<a href="{% url 'project_details' pk=project.pk %}">Details</a>
{% if project.max_members > project.participants.count %}
<button type="button"> Join!</button>
{% endif %}
<!-- <p class="lead">Check out <a href="projects/">ongoing projects</a> that sick out participants and choose the idea and technology you want to work on.</p> -->
</div>

<div class="col-lg-5 col-lg-offset-2 col-sm-6">
<hr class="section-heading-spacer">
<div class="clearfix"></div>
<!--<img class="img-responsive" src="/static/img/ipad-python.png" alt="" >!-->
{% if project.image %}
<img src = "{{project.image.url}}">
{% endif %}
</div>
{% endfor %}
</div>
{% endfor %}

</div>
<!-- /.container -->

</div>

Expand Down
17 changes: 14 additions & 3 deletions projects/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
from django.conf.urls import url
from projects.views import ProjectListView, ProjectCreate
from projects.views import (ProjectListView, ProjectCreate, ProjectDetailView,
ProjectUpdate)


urlpatterns = [

url(r'^$', ProjectListView.as_view(), name='project_list'),
url(r'^create/$', ProjectCreate.as_view(), name='project_create'),
url(r'^$',
ProjectListView.as_view(),
name='project_list'),
url(r'^details/(?P<pk>\d+)/$',
ProjectDetailView.as_view(),
name='project_details'),
url(r'^create/$',
ProjectCreate.as_view(),
name='project_create'),
url(r'^details/(?P<pk>\d+)/update/$',
ProjectUpdate.as_view(),
name='project_update'),
]
17 changes: 9 additions & 8 deletions projects/views.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
from django.views.generic.list import ListView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from django.core.urlresolvers import reverse_lazy
from .models import Project


class ProjectCreate(CreateView):
template_name = 'projects/create_project.html'
model = Project
fields = '__all__'
fields = ['title', 'description', 'max_members', 'difficulty',
'image', 'participants', 'coach', 'owner']
success_url = reverse_lazy('project_list')


class ProjectUpdate(UpdateView):
model = Project
fields = '__all__'
success_url = reverse_lazy('project_list')
fields = ['title', 'description', 'max_members', 'difficulty',
'image', 'participants', 'coach']
success_url = reverse_lazy('project_details')


class ProjectDelete(DeleteView):
class ProjectListView(ListView):
model = Project
success_url = reverse_lazy('project_list')


class ProjectListView(ListView):
class ProjectDetailView(DetailView):
model = Project

0 comments on commit a8e1dc2

Please sign in to comment.