Skip to content

Commit

Permalink
Add hunches/:id/evidence/:id page.
Browse files Browse the repository at this point in the history
  • Loading branch information
adammck committed Dec 19, 2011
1 parent 9c548a5 commit 9231d85
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 70 deletions.
66 changes: 31 additions & 35 deletions hunchworks/static/css/pages/evidence.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,44 @@
}
}

article.evidence.full {

#evidence-show {
> header {
text-align: center;
padding: 4em;

article.evidence {

> header {
text-align: center;
padding: 4em;

> div.embed {
img, object, embed {
display: block;
margin: 0 auto;
border-radius: 4px;
-moz-border-radius: 4px;
}
> div.embed {
img, object, embed {
display: block;
margin: 0 auto;
border-radius: 4px;
-moz-border-radius: 4px;
}
}

> h1 {
margin-top: 0.4em;
font-size: 250%;
> h1 {
margin-top: 0.4em;
font-size: 250%;

> a {
text-decoration: none;
color: #000;
}
> a {
text-decoration: none;
color: #000;
}
}

> section.desc {
border: 1px solid #ccc;
background: #ffe;
box-shadow: 5px 5px 10px #eee;
border-radius: 4px;
-moz-border-radius: 4px;
text-align: left;
padding: 2em;

p {
font-size: 125%;
margin-top: 0.4em;
line-height: 1.4;
}
> section.desc {
border: 1px solid #ccc;
background: #ffe;
box-shadow: 5px 5px 10px #eee;
border-radius: 4px;
-moz-border-radius: 4px;
text-align: left;
padding: 2em;

p {
font-size: 125%;
margin-top: 0.4em;
line-height: 1.4;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion hunchworks/templates/evidences/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ <h1>Show an Evidence</h1>
{% endblock %}

{% block content %}
<article class="evidence">
<article class="evidence full">
<header>
{% if evidence.link %}
{% embed evidence.link %}
Expand Down
2 changes: 1 addition & 1 deletion hunchworks/templates/hunches/show/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h2>{{ hunch.privacy_text }}</h2>
<ul>
<li class="{% ifactive "hunch" hunch.pk %}active {% endifactive %}{% block overview_tab_class %}{% endblock %}"><a href="{% url hunch hunch.pk %}">Overview</a></li>
<li class="{% ifactive "hunch_activity" hunch.pk %}active {% endifactive %}{% block activity_tab_class %}{% endblock %}"><a href="{% url hunch_activity hunch.pk %}">Activity</a></li>
<li class="{% ifactive "hunch_evidence" hunch.pk %}active {% endifactive %}{% block evidence_tab_class %}{% endblock %}"><a href="{% url hunch_evidence hunch.pk %}">Evidence <span>{{ hunch.evidence_count }}</span></a></li>
<li class="{% ifactive "hunch_evidences" hunch.pk %}active {% endifactive %}{% block evidence_tab_class %}{% endblock %}"><a href="{% url hunch_evidences hunch.pk %}">Evidence <span>{{ hunch.evidence_count }}</span></a></li>
<li class="{% ifactive "hunch_comments" hunch.pk %}active {% endifactive %}{% block comments_tab_class %}{% endblock %}"><a href="{% url hunch_comments hunch.pk %}">Comments <span>{{ hunch.comment_count }}</span></a></li>
<li class="{% ifactive "hunch_contributors" hunch.pk %}active {% endifactive %}{% block contributors_tab_class %}{% endblock %}"><a href="{% url hunch_contributors hunch.pk %}">Contributors <span>{{ hunch.contributor_count }}</span></a></li>
</ul>
Expand Down
56 changes: 26 additions & 30 deletions hunchworks/templates/hunches/show/evidence.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
{% extends "hunches/show/base.html" %}
{% load paginator_tags %}
{% load bookmark_tags %}
{% load embed_tags %}
{% load markup %}

{% block title %}
Evidence &mdash;
{{ block.super }}
{% endblock %}

{% block secondary_content %}
{% if hunch_evidences.object_list %}

<section class="object-list evidence">
{% for object in hunch_evidences.object_list %}

<article class="evidence short" data-id="{{ object.evidence.id }}">
{% embed object.evidence.link %}
<h2><a href="">{{ object.evidence }}</a></h2>

<ul class="stats">
<li>Added by: {{ object.creator }}</li>
<li>Comments: {{ object.comment_set.count }}</li>
<li>Votes: {{ object.vote_set.count }}</li>
</ul>
</article>
{% block evidence_tab_class %}active{% endblock %}

{% endfor %}
</section>

{% include "includes/evidences/list.html" with object_list=evidences.object_list %}
{% else %}
<div class="empty-list">
<p>No evidence has been added to this hunch yet.</p>
</div>
{% endif %}
{% endblock %}

{% block paginator %}
{% paginator hunch_evidences %}
{% block secondary_content %}
<article class="evidence full">
<header>
{% if evidence.link %}
{% embed evidence.link %}
<h1><a href="{{ evidence.get_absolute_url }}">{{ evidence }}</a></h1>
{% else %}
<section class="desc">
{{ evidence.description|markdown }}
</section>

<h1><a href="{{ evidence.get_absolute_url }}">{{ evidence }}</a></h1>
{% endif %}
</header>

<!--<ul class="meta">
<li class="source"><span>Source:</span> <a href="{{ evidence.link }}">{{ evidence.short_link }}</a></li>
<li class="date"><span>Posted:</span> {{ evidence.time_created|date:"j F Y" }}</li>
<li class="creator"><span>By:</span> <a href="{{ evidence.creator.get_absolute_url }}">{{ evidence.creator }}</a></li>
</ul>-->

{% bookmarks evidence %}
</article>
{% endblock %}
40 changes: 40 additions & 0 deletions hunchworks/templates/hunches/show/evidences.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends "hunches/show/base.html" %}
{% load paginator_tags %}
{% load embed_tags %}

{% block title %}
Evidence &mdash;
{{ block.super }}
{% endblock %}

{% block secondary_content %}
{% if hunch_evidences.object_list %}

<section class="object-list evidence">
{% for object in hunch_evidences.object_list %}

<article class="evidence short" data-id="{{ object.evidence.id }}">
{% embed object.evidence.link %}
<h2><a href="{% url hunch_evidence object.hunch.id, object.evidence.id %}">{{ object.evidence }}</a></h2>

<ul class="stats">
<li>Added by: {{ object.creator }}</li>
<li>Comments: {{ object.comment_set.count }}</li>
<li>Votes: {{ object.vote_set.count }}</li>
</ul>
</article>

{% endfor %}
</section>

{% include "includes/evidences/list.html" with object_list=evidences.object_list %}
{% else %}
<div class="empty-list">
<p>No evidence has been added to this hunch yet.</p>
</div>
{% endif %}
{% endblock %}

{% block paginator %}
{% paginator hunch_evidences %}
{% endblock %}
4 changes: 3 additions & 1 deletion hunchworks/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
url(r"^hunches/open$", hunches.open, name="open_hunches"),
url(r"^hunches/(?P<hunch_id>\d+)$", hunches.show, name="hunch"),
url(r"^hunches/(?P<hunch_id>\d+)/activity$", hunches.activity, name="hunch_activity"),
url(r"^hunches/(?P<hunch_id>\d+)/evidence$", hunches.evidence, name="hunch_evidence"),
url(r"^hunches/(?P<hunch_id>\d+)/comments$", hunches.comments, name="hunch_comments"),
url(r"^hunches/(?P<hunch_id>\d+)/contributors$", hunches.contributors, name="hunch_contributors"),
url(r"^hunches/(?P<hunch_id>\d+)/permissions$", hunches.permissions, name="hunch_permissions"),
Expand All @@ -63,6 +62,9 @@
url(r"^hunches/(?P<hunch_id>\d+)/follow$", hunches.follow, name="follow_hunch"),
url(r"^hunches/(?P<hunch_id>\d+)/unfollow$", hunches.unfollow, name="unfollow_hunch"),

url(r"^hunches/(?P<hunch_id>\d+)/evidence$", hunches.hunch_evidences, name="hunch_evidences"),
url(r"^hunches/(?P<hunch_id>\d+)/evidence/(?P<evidence_id>\d+)$", hunches.hunch_evidence, name="hunch_evidence"),

# create hunch wizard
url(r'^hunches/create$', hunches.HunchWizard.as_view([
forms.hunch.HunchFormOne,
Expand Down
17 changes: 15 additions & 2 deletions hunchworks/views/hunches.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,29 @@ def activity(req, hunch_id):


@login_required
def evidence(req, hunch_id):
def hunch_evidences(req, hunch_id):
hunch = get_object_or_404(models.Hunch, pk=hunch_id)
hunch_evidences = paginated(req, models.HunchEvidence.objects.filter(hunch=hunch), 20)

return _render(req, "show/evidence", {
return _render(req, "show/evidences", {
"hunch": hunch,
"hunch_evidences": hunch_evidences,
})


@login_required
def hunch_evidence(req, hunch_id, evidence_id):
hunch = get_object_or_404(models.Hunch, pk=hunch_id)
evidence = get_object_or_404(models.Evidence, pk=evidence_id)
hunch_evidence = models.HunchEvidence.objects.get(hunch=hunch_id, evidence=evidence_id)

return _render(req, "show/evidence", {
"hunch": hunch,
"evidence": evidence,
"hunch_evidence": hunch_evidence,
})


@login_required
def comments(req, hunch_id):
hunch = get_object_or_404(
Expand Down

0 comments on commit 9231d85

Please sign in to comment.