Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Single quotes #46

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
37 changes: 37 additions & 0 deletions strecklista/templates/strecklista/components/quote.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

.card {
align-items: center;
box-shadow: 0 1px 5px 0 rgba(0,0,0,.3);
display: flex;
flex: 1;
margin: 1em .5em;
padding: 1em;
border-radius: 2px;
justify-content: space-between;
}
.card.quote {
align-items: inherit;
flex-direction: column;
font-size: 1.2em;
}
.quote-text {
font-size: 1.2em;
}
.quote-meta {
font-style: italic;
text-align: right;
}
.quotee::before {
content: '\2014\00a0';
}
.detail {
color: #555;
font-size: .75em;
}
#status:not(.alert-success):not(.alert-danger) {
display: none;
}

.quote-link{
font-size: .6em;
}
3 changes: 3 additions & 0 deletions strecklista/templates/strecklista/components/quotecard.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
<div class="quotee">{{ quote.who }}</div>
<div class="detail">{{ quote.timestamp }}</div>
</div>
<div class="quote-link">
Permanent länk: <a href="{{ request.get_host }}/quote/{{ quote.id }}">{{ request.get_host }}/quote/{{ quote.id }}</a>
Copy link
Member

@reinefjord reinefjord May 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anchor must have the protocol in href, otherwise request.get_host is interpreted as the protocol. Should be href="//{{ request.get_host C}}[...]", note the //. Isn't {% url 'view.name' quote=quote.id %} the correct way to do this though?

Also, <a href="...">Permanent länk</a> is IMHO better UX. It's how hyperlinks are intended to be used.

</div>
</div>
34 changes: 2 additions & 32 deletions strecklista/templates/strecklista/quotes.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
{% extends 'strecklista/base.html' %}
{% block content %}
<style>
.card {
align-items: center;
box-shadow: 0 1px 5px 0 rgba(0,0,0,.3);
display: flex;
flex: 1;
margin: 1em .5em;
padding: 1em;
border-radius: 2px;
justify-content: space-between;
}
.card.quote {
align-items: inherit;
flex-direction: column;
font-size: 1.2em;
}
.quote-text {
font-size: 1.2em;
}
.quote-meta {
font-style: italic;
text-align: right;
}
.quotee::before {
content: '\2014\00a0';
}
.detail {
color: #555;
font-size: .75em;
}
#status:not(.alert-success):not(.alert-danger) {
display: none;
}
{% include 'strecklista/components/quote.css' %}
</style>

<script>
$(function() {
$('#quoteForm').on('submit', function(e) {
Expand Down
17 changes: 17 additions & 0 deletions strecklista/templates/strecklista/single_quote.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends 'strecklista/base.html' %}
{% block content %}
<style>
{% include 'strecklista/components/quote.css' %}
</style>

{% include "strecklista/snippets/navbar.html" %}
<div class="container">
<h1>Citat</h1>


<div id="quoteDiv">
{% include 'strecklista/components/quotecard.html' with quote=quote %}
</div>
<a href="/quote/">Visa alla citat</a>
</div>
{% endblock %}
3 changes: 3 additions & 0 deletions strecklista/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
url(r'^login', views.login, name='login'),
url(r'^profile/(?P<user_id>[0-9]+)', views.profile, name='profile'),
url(r'^bulkTransactions/', views.bulkTransactions, name='bulkTransactions'),

url(r'^quote/(?P<quote_id>[0-9]+)', views.singleQuote, name='singleQuote'),
url(r'^quote/', views.quote, name='quote'),

url(r'^submitQuote/', views.submitQuote, name='submitQuote'),

url(r'^heddaHopper/', views.heddaHopper, name='heddaHopper'),
Expand Down
9 changes: 9 additions & 0 deletions strecklista/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ def quote(request):
'quotes': Quote.objects.order_by('-id'),
})

@login_required
def singleQuote(request, quote_id):
return render(request, 'strecklista/single_quote.html', {
'form': QuoteForm(),
'quote': Quote.objects.filter(id=quote_id).first(),
})




@login_required
def product(request):
Expand Down