Skip to content

Commit

Permalink
user profile now correctly sorts records as active/fulfilled, which l…
Browse files Browse the repository at this point in the history
…ive on separate tabs

could be much prettier...
  • Loading branch information
djudd committed Jan 14, 2012
1 parent 8f9f564 commit c24f8d0
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 98 deletions.
8 changes: 5 additions & 3 deletions profiles/views.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class ProfileDetailView(ProfileViewMixin, DetailView):
max_records = 10 # max. records to display in activity stream max_records = 10 # max. records to display in activity stream


def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
""" Adds records recently created by user to the context """ """ Adds records recently created by user to the context """
records = self.object.records_created.order_by('-created')

context = super(ProfileDetailView, self).get_context_data(**kwargs) context = super(ProfileDetailView, self).get_context_data(**kwargs)
context['records'] = self.object.records_created.order_by( context['active_records'] = records.filter(status=0)[:self.max_records]
'-created')[:self.max_records] context['fulfilled_records'] = records.filter(status=2)[:self.max_records]
return context return context


class ProfileUpdateForm(ModelForm): class ProfileUpdateForm(ModelForm):
Expand Down
135 changes: 40 additions & 95 deletions templates/profiles/profile_detail.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,35 @@
{% load gravatar %} {% load gravatar %}
{% load record_type %} {% load record_type %}
{% block extrajs %} {% block extrajs %}
<script type="text/javascript">
$(function () {
var tabContainers = $('#tabs').find('div.tab');
var tabLinks = $('#tab-links').find('a.tab');

tabLinks.click(function () {
tabContainers.hide().filter(this.hash).show();

tabLinks.removeClass('selected');
$(this).addClass('selected');

return false;
});

tabLinks.filter(':first').click();
});
</script>
<script src="/static/js/profiles.js"></script> <script src="/static/js/profiles.js"></script>

<style type="text/css">
a.tab {
padding-left: 15px;
color: #B0B0B0 !important;
}

a.tab.selected {
color: #000000 !important;
}
</style>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="grid_16 mtx"> <div class="grid_16 mtx">
Expand Down Expand Up @@ -58,70 +86,24 @@ <h2 class="gray-text mbn">status</h2>
<div class="grid_12 omega"> <div class="grid_12 omega">


{% include "profiles/profile_header.html" with include_edit_link="true" %} {% include "profiles/profile_header.html" with include_edit_link="true" %}


<div class="grid_7 omega"> <div id="tabs" class="grid_12 omega">

<section class="mod rounded gray profile"> <section class="mod rounded gray profile">

<header> <header>
<div class="stripes line"> <div class="stripes">
<div class="size1of5 left tcenter"> <ul id="tab-links">
<h3><a href="#active">active</a></h3> <li class="size1of5 left"><h4><a class="tab" href="#active">Active</a></h4></li>
</div> <li class="size1of3 left"><h4><a class="tab" href="#fulfilled">Fulfilled</a></h4></li>
<!-- </ul>
<div class="size1of3 left stripes-arrow tcenter">
<h3><a href="@TODO">about</a></h3>
</div>
<div class="size1of3 left stripes tcenter">
<h3><a href="@TODO">testimonials</a></h3>
</div>
-->
</div> </div>
</header> </header>


<div id="active" class="bd"> <div id="active" class="tab bd">

{% include "profiles/record_column.html" with records=active_records %}
<!-- activity content here --> </div>


<div id="wishes" class="bd"> <div id="fulfilled" class="tab bd">

{% include "profiles/record_column.html" with records=fulfilled_records %}
{% for record in records %}
{% if record|record_type == 'gift' %}
<div class="mod speech clearfix">
<div class="left mll plm relative" style="margin-left: 5px !important;padding-left: 5px !important;">
{% gravatar record.user.user 80 %}
{# <div class="bg occupier-small" title="Wall Street Occupier">Wall Street Occupier</div> #}
</div>
<div class="left arrow-left mls">
<div class="pam" style="width:180px;">
<strong>{{ record.title }}</strong>
</div>
</div>
<div class="left view mlm">
<a href="{{ record.get_absolute_url }}" class="button profile-gift-button">view</a>
</div>
</div>
{% endif %}
{% if record|record_type == 'wish' %}
<div class="mod speech clearfix">
<div class="left view mlm" style="padding-right:5px;">
<a href="{{ record.get_absolute_url }}" class="wish button profile-wish-button">view</a>
</div>
<div class="left arrow-right mls">
<div class="pam" style="width:180px;">
<strong>{{ record.title }}</strong>
</div>
</div>
<div class="left mll plm relative" style="margin-left:2px !important;padding-left:2px !important;">
{% gravatar record.user.user 80 %}
{# <div class="bg occupier-small" title="Wall Street Occupier">Wall Street Occupier</div> #}
</div>
</div>
{% endif %}
{% endfor %}

</div>

</div> </div>


<footer class="mbl mhm" style="border-top: 1px dashed #CCC;"> <footer class="mbl mhm" style="border-top: 1px dashed #CCC;">
Expand All @@ -131,43 +113,6 @@ <h3><a href="@TODO">testimonials</a></h3>
color: #7FD1D0;margin-left: 0px !important; padding-left: 0px !important;">post new wish</a> color: #7FD1D0;margin-left: 0px !important; padding-left: 0px !important;">post new wish</a>
</footer> </footer>
</section> </section>

</div>

<div class="grid_5 omega">

<section class="mod rounded gray profile">

<header>
<div class="stripes line">
<div class="size1of3 left stripes tcenter" id="wishesContainer">
<h3 class=""><a href="#fulfilled">fulfilled</a></h3>
</div>
<!--<div class="size1of3 left stripes tcenter" id="giftsContainer">
<h3 class=""><a href="#" id="giftsClick">gifts</a></h3>
</div>
<div class="size1of3 left stripes tcenter">
<h3 class=""> </h3>
</div>-->
</div>
</header>

<div class="bd">

<div id="wishes" class="bd">

</div>

<div id="gifts" class="bd">

</div>

</div>

</section>

</div>

</div> </div>
<!-- end main content --> <!-- end main content -->


Expand Down
37 changes: 37 additions & 0 deletions templates/profiles/record_column.html
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,37 @@
{% load record_type %}
{% load gravatar %}
{% for record in records %}
{% if record|record_type == 'gift' %}
<div class="mod speech clearfix">
<div class="left mll plm relative" style="margin-left: 5px !important;padding-left: 5px !important;">
{% gravatar record.user.user 60 %}
{# <div class="bg occupier-small" title="Wall Street Occupier">Wall Street Occupier</div> #}
</div>
<div class="left arrow-left mls">
<div class="pam" style="width:180px;">
<strong>{{ record.title }}</strong>
</div>
</div>
<div class="left view mlm">
<a href="{{ record.get_absolute_url }}" class="button profile-gift-button">view</a>
</div>
</div>
{% endif %}
{% if record|record_type == 'wish' %}
<div class="mod speech clearfix">
<div class="left view mlm" style="padding-right:5px;">
<a href="{{ record.get_absolute_url }}" class="wish button profile-wish-button">view</a>
</div>
<div class="left arrow-right mls">
<div class="pam" style="width:180px;">
<strong>{{ record.title }}</strong>
</div>
</div>
<div class="left mll plm relative" style="margin-left: 2px !important;padding-left: 2px !important;">
{% gravatar record.user.user 60 %}
{# <div class="bg occupier-small" title="Wall Street Occupier">Wall Street Occupier</div> #}
</div>
</div>
{% endif %}
{% endfor %}

0 comments on commit c24f8d0

Please sign in to comment.