Skip to content

Commit c8e091a

Browse files
Adicionado box ultimos posts
1 parent 5e5fb35 commit c8e091a

File tree

7 files changed

+28
-1
lines changed

7 files changed

+28
-1
lines changed

blog/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
def artigo(request, slug):
99
tags = Tag.objects.all().order_by("nome")
10+
artigos = Artigo.objects.all()
1011
artigo = get_object_or_404(Artigo, slug=slug)
1112
return render_to_response('blog/artigo.html', locals(),
1213
context_instance=RequestContext(request))
1314

1415
def sobre_mim(request):
1516
tags = Tag.objects.all().order_by("nome")
17+
artigos = Artigo.objects.all()
1618
return render_to_response('blog/sobre-mim.html', locals(),
1719
context_instance=RequestContext(request))
1820

media/stylesheets/base.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ div.links {
185185
background-color: #ff3e3e;
186186
}
187187

188+
/* Box Ultimos Posts */
189+
190+
div.ultimos_posts {
191+
background-color: #769cc1;
192+
}
193+
194+
188195
/* Topo */
189196

190197
div.topo {

tags/views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from django.template import RequestContext
44

55
from models import Tag
6+
from blog.models import Artigo
67

78
def tag(request, tag_nome):
89
tags = Tag.objects.all().order_by("nome")
910
tag = get_object_or_404(Tag, nome=tag_nome)
11+
artigos = Artigo.objects.all()
1012
return render_to_response(
1113
'tags/tag.html',
1214
locals(),

templates/base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ <h1 style="display: none;">Blog do Hugo Maia Vieira</h1>
5858
{% include "twitter.html" %}
5959
{% include "categorias.html" %}
6060
{% include "links.html" %}
61+
{% include "ultimos_posts.html" %}
6162
</div>
6263

6364
</div>

templates/ultimos_posts.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="box ultimos_posts">
2+
<h3>Últimos posts</h3>
3+
<ul>
4+
{% for artigo in artigos|slice:":10" %}
5+
<li>
6+
<a href="{{ artigo.get_absolute_url }}" alt="{{ artigo.titulo }}">
7+
{{ artigo.titulo }}
8+
</a>
9+
</li>
10+
{% endfor %}
11+
</ul>
12+
</div>
13+

urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
blog_dict = {
1212
'queryset': Artigo.objects.all(),
1313
'paginate_by': 10,
14-
'extra_context': {'tags': Tag.objects.all().order_by("nome")}
14+
'extra_context': {'tags': Tag.objects.all().order_by("nome"), 'artigos': Artigo.objects.all()}
1515
}
1616

1717
urlpatterns = patterns('',

views.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.core.mail import send_mail
55

66
from tags.models import Tag
7+
from blog.models import Artigo
78

89
class FormContato(forms.Form):
910
nome = forms.CharField(max_length=50, required=True)
@@ -34,6 +35,7 @@ def enviar(self):
3435

3536
def contato(request):
3637
tags = Tag.objects.all().order_by("nome")
38+
artigos = Artigo.objects.all()
3739

3840
if request.method == 'POST':
3941
form = FormContato(request.POST)

0 commit comments

Comments
 (0)