Permalink
Browse files

Front-end task : Live Ad listed in homepage

  • Loading branch information...
1 parent 921f335 commit 150babb0cebcb8631557a708a20ffcf32aa166ab @writefaruq committed Jan 5, 2012
Showing with 34 additions and 32 deletions.
  1. +23 −3 apps/admanager/views.py
  2. +7 −25 templates/banner_base.html
  3. +4 −4 urls.py
@@ -2,16 +2,36 @@
from django.shortcuts import render_to_response
from django.template import RequestContext
-from apps.admanager.models import Ad
-from apps.admanager.forms import CreateAdForm
+from noticeboard.apps.admanager.models import Ad
+from noticeboard.apps.admanager.forms import CreateAdForm
+
+from noticeboard.apps.profiles.models import Profile
+
+def _get_customer(user):
+ try:
+ user_profile = Profile.objects.get(user=user)
+ return Customer.objects.get(user_profile=user_profile)
+ except Exception:
+ raise
+
+def homepage(request):
+ """
+ Shows all live ads of current user
+ """
+ ads = Ad.objects.filter(status=Ad.LIVE)
+ context = {
+ "ads": ads,
+ }
+ context = RequestContext(request, context)
+ return render_to_response("homepage.html", context)
@login_required
def ads(request):
"""
Lists ads of current user
"""
- ads = Ad.objects.filter(owner=request.user)
+ ads = Ad.objects.filter(owner=_get_customer(request.user))
context = {
"ads": ads,
}
@@ -12,36 +12,18 @@
<p><a class="btn primary large">Learn more &raquo;</a></p>
{% endblock %}
</div>
-
+
<div class="row">
<div class="span4">
- {% block column-1 %}
- <h2>Heading</h2>
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sed viverra dui. Aenean blandit faucibus tincidunt. Phasellus fermentum elit ut erat varius cursus. Nunc posuere mauris sit amet enim congue quis elementum lectus tincidunt. Cras vel tempus metus.</p>
- <p><a class="btn" href="#">View details &raquo;</a></p>
- {% endblock %}
- </div>
- <div class="span4">
- {% block column-2 %}
- <h2>Heading</h2>
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sed viverra dui. Aenean blandit faucibus tincidunt. Phasellus fermentum elit ut erat varius cursus. Nunc posuere mauris sit amet enim congue quis elementum lectus tincidunt. Cras vel tempus metus.</p>
- <p><a class="btn" href="#">View details &raquo;</a></p>
- {% endblock %}
- </div>
- <div class="span4">
- {% block column-3 %}
- <h2>Heading</h2>
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sed viverra dui. Aenean blandit faucibus tincidunt. Phasellus fermentum elit ut erat varius cursus. Nunc posuere mauris sit amet enim congue quis elementum lectus tincidunt. Cras vel tempus metus.</p>
- <p><a class="btn" href="#">View details &raquo;</a></p>
- {% endblock %}
- </div>
- <div class="span4">
- {% block column-4 %}
- <h2>Heading</h2>
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sed viverra dui. Aenean blandit faucibus tincidunt. Phasellus fermentum elit ut erat varius cursus. Nunc posuere mauris sit amet enim congue quis elementum lectus tincidunt. Cras vel tempus metus.</p>
+ {% for ad in ads %}
+ {% block column-{{ad.id}} %}
+ <h2>{{ad.title}}</h2>
+ <p>{{ad.description}}</p>
<p><a class="btn" href="#">View details &raquo;</a></p>
{% endblock %}
+ {% endfor %}
</div>
+
</div>
</div>
{% endblock %}
View
@@ -7,14 +7,14 @@
from pinax.apps.account.openid_consumer import PinaxConsumer
+from apps.admanager.models import Ad
+from apps.admanager.views import homepage
handler500 = "pinax.views.server_error"
-
+ads = Ad.objects.filter(status=Ad.LIVE)
urlpatterns = patterns("",
- url(r"^$", direct_to_template, {
- "template": "homepage.html",
- }, name="home"),
+ url(r"^$", homepage, name="home"),
url(r"^admin/invite_user/$", "pinax.apps.signup_codes.views.admin_invite_user", name="admin_invite_user"),
url(r"^admin/", include(admin.site.urls)),
url(r"^about/", include("about.urls")),

0 comments on commit 150babb

Please sign in to comment.