Skip to content

Commit

Permalink
updated views and individual stock templates
Browse files Browse the repository at this point in the history
  • Loading branch information
williadav committed Sep 8, 2023
1 parent 9359848 commit cf64c55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 12 additions & 1 deletion chemie/stock/templates/stock/individualstock.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@

<h><b>{{name}}</b></h>

<p>Beskrivelse: {{desc}}</p>
<div style = "display: flex; flex-direction: row; margin: 10px; padding: 20px">

<div style = "display: flex; flex-direction: column; margin: 10px; padding: 20px">
<p>Beskrivelse: {{desc}}</p>
<p>Value: {{value}}</p>
</div>

<div style= "display: flex;flex-direction: row; margin: 10px; padding: 20px">
<button type = "button" style = "background-color: green; width: 100px; height: 100px">Kjøp</button>
<button type = "button" style = "background-color: red;width: 100px; height: 100px">Selg</button>
</div>

</div>
{% endblock content %}
9 changes: 5 additions & 4 deletions chemie/stock/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ def index(request):

def stock_index(request, id):

stocktypes = Stocktype.objects.all()
stocktype = stocktypes.get(id = id)
stocktype = get_object_or_404(Stocktype, id = id)

name = stocktype.name
desc = stocktype.desc
value = stocktype.history_set.order_by("-date").first().value

#volume
#value

context = {
"name":name,
"desc":desc
"desc":desc,
"value":value
}

return render(request, "stock/individualstock.html", context)
Expand Down

0 comments on commit cf64c55

Please sign in to comment.