Skip to content
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

add update and details features #49

Merged
merged 2 commits into from
Mar 11, 2016
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
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