Browse files

So many changes. I keep forgetting to commit.

  • Loading branch information...
1 parent 2d8cde9 commit 5e18669deb7082196ad77bf24d4594281ef2e687 Eric Florenzano committed Sep 4, 2008
View
6 events/models.py
@@ -33,9 +33,9 @@ def __unicode__(self):
return self.description[:76] + ' ...'
return self.description[:80]
- def save(self):
+ def save(self, **kwargs):
Event.objects.today().filter(creator=self.creator).update(latest=False)
- super(Event, self).save()
+ super(Event, self).save(**kwargs)
def today(self):
now = datetime.now()
@@ -61,4 +61,4 @@ def __unicode__(self):
return "%s is attending %s" % (self.user.username, self.event)
class Meta(object):
- verbose_name_plural = "Attendance"
+ verbose_name_plural = "Attendance"
View
39 media/css/screen.css
@@ -1,5 +1,6 @@
/* General Stuff */
body { background: #000000 url('../img/background.jpg') no-repeat 50% 0; color: white; }
+h2 { font-size: 18px; }
/* Logo */
#logo a {
@@ -89,7 +90,7 @@ ul.messages li a.clear_button {
}
/* Person */
-div.person { margin: 1px 20px 10px 0px; float: left; }
+div.person { margin: 1px 10px 10px 0px; float: left; }
div.person a { text-decoration: none; }
div.person .username {
float: left;
@@ -117,12 +118,10 @@ div.event span.description_small {
padding: 20px 10px 0px 0px;
}
div.event span.description_medium {
- text-indent: -58px;
display: block;
padding: 10px 10px 0px 0px;
}
div.event span.description_large {
- text-indent: -58px;
display: block;
padding: 2px 10px 0px 0px;
}
@@ -282,6 +281,40 @@ p.event_time_first {
#all_events_title { margin-top: 20px; }
#attendees_title { margin-top: 20px; }
+/* Forms */
+form.standard {
+ background: url('../img/form_bg.png');
+ border: 1px solid #565169;
+ padding: 10px;
+ margin: 10px;
+}
+form.standard input, form textarea {
+ color: #FFFFFF;
+ font-weight: bold;
+ font-size: 14px;
+ background: url('../img/formfield_bg.png');
+ border: 1px solid #AfAAC4;
+}
+form.standard ul li { list-style-type: none; margin-left: 0px; }
+form.standard ul li label { display: block; }
+form.standard a { color: #FF4444; text-decoration: none; }
+
+/* Follow/Unfollow */
+div.follow {
+ width: 80px;
+ height: 80px;
+ display: table-cell;
+ display: inline-block;
+}
+div.follow div.person { margin-bottom: 0px; margin-left: 8px; }
+div.follow input {
+ background: url('../img/formfield_bg.png');
+ border: 1px solid #afaac4;
+ width: 78px;
+ color: white;
+ font-weight: bold;
+}
+
/* Pagination */
.pagination {
font-weight: bold;
View
BIN media/img/form_bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN media/img/formfield_bg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
15 media/js/global.js
@@ -28,15 +28,24 @@ $(function() {
}).mouseout(function() {
$(this).fadeTo('fast', 0.6);
});
- $('#nav > li > span').mouseover(function() {
+ $('#nav > li > span.subnav_everyone').mouseover(function() {
var pos = $('#nav > li > span').position();
- $('#nav > li > ul')
+ $('#nav > li > ul.subnav_everyone')
.css('position', 'absolute')
.css('top', pos['top'] + 35 + 'px')
.css('left', pos['left'] - 22 + 'px')
.css('display', 'block')
.css('z-index', '999');
});
+ $('#nav > li > span.subnav_friends').mouseover(function() {
+ var pos = $('#nav > li > span').position();
+ $('#nav > li > ul.subnav_friends')
+ .css('position', 'absolute')
+ .css('top', pos['top'] + 35 + 'px')
+ .css('left', pos['left'] + 90 + 'px')
+ .css('display', 'block')
+ .css('z-index', '999');
+ });
$('#nav > li > ul').bind("mouseleave", function() {
$('#nav > li > ul').css('display', 'none');
});
@@ -52,6 +61,7 @@ $(function() {
return false;
});
});
+ /* TODO: Uncomment this if you want to be annoyed.
$('div.person').livequery(function() {
$(this).mouseover(function() {
$(this).animate({'marginRight': '16px', 'marginBottom': '0px'}, "fast")
@@ -69,6 +79,7 @@ $(function() {
.fadeTo('fast', 0.7);
});
});
+ */
$('#event_form').ajaxForm({
clearForm: true,
beforeSubmit: function(formData, jqForm, options) {
View
4 media/js/unitpngfix.js
@@ -0,0 +1,4 @@
+var clear="images/clear.gif" //path to clear.gif
+
+pngfix=function(){var els=document.getElementsByTagName('*');var ip=/\.png/i;var i=els.length;while(i-- >0){var el=els[i];var es=el.style;if(el.src&&el.src.match(ip)&&!es.filter){es.height=el.height;es.width=el.width;es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";el.src=clear;}else{var elb=el.currentStyle.backgroundImage;if(elb.match(ip)){var path=elb.split('"');var rep=(el.currentStyle.backgroundRepeat=='no-repeat')?'crop':'scale';es.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";es.height=el.clientHeight+'px';es.backgroundImage='none';var elkids=el.getElementsByTagName('*');if (elkids){var j=elkids.length;if(el.currentStyle.position!="absolute")es.position='static';while (j-- >0)if(!elkids[j].style.position)elkids[j].style.position="relative";}}}}}
+window.attachEvent('onload',pngfix);
View
1 profile/__init__.py
@@ -1,2 +1 @@
-
View
6 profile/urls.py
@@ -0,0 +1,6 @@
+from django.conf.urls.defaults import *
+
+urlpatterns = patterns('profile.views',
+ url(r'^detail/(?P<username>[a-zA-Z0-9_-]+)/$', 'detail',
+ name='profile_detail'),
+)
View
30 profile/views.py
@@ -0,0 +1,30 @@
+from django.shortcuts import get_object_or_404, render_to_response
+from django.template import RequestContext
+from django.contrib.auth.models import User
+from socialgraph.util import get_people_user_follows, get_people_following_user
+from socialgraph.util import get_mutual_followers
+from events.models import Event, Attendance
+
+def detail(request, username=None):
+ user = get_object_or_404(User, username=username)
+ events_created = list(Event.objects.filter(creator=user, latest=True).order_by('-creation_date')[:10])
+ attended = Attendance.objects.filter(user=user).order_by('-registration_date')[:10]
+ events_attended = list(Event.objects.filter(id__in=[e.event.id for e in attended]).order_by('-creation_date'))
+ people_following_user = get_people_following_user(user)
+ context = {
+ 'profile_user': user,
+ 'people_following_user': people_following_user,
+ 'people_user_follows': get_people_user_follows(user),
+ 'mutual_followers': get_mutual_followers(user),
+ 'events_created': events_created,
+ 'num_events_created': len(events_created),
+ 'events_attended': events_attended,
+ 'num_events_attended': len(events_attended),
+ 'friend': request.user in people_following_user,
+ }
+ return render_to_response(
+ 'profile/detail.html',
+ context,
+ context_instance = RequestContext(request)
+ )
+
View
4 socialgraph/forms.py
@@ -0,0 +1,4 @@
+from django import forms
+
+class SearchForm(forms.Form):
+ q = forms.CharField(max_length=50)
View
6 socialgraph/models.py
@@ -11,10 +11,10 @@ def __unicode__(self):
return "%s is following %s" % (self.from_user.username,
self.to_user.username)
- def save(self):
+ def save(self, **kwargs):
if self.from_user == self.to_user:
raise ValueError("Cannot follow yourself.")
- super(UserLink, self).save()
+ super(UserLink, self).save(**kwargs)
class Meta:
- unique_together = (('to_user', 'from_user'),)
+ unique_together = (('to_user', 'from_user'),)
View
13 socialgraph/urls.py
@@ -1,24 +1,22 @@
from django.conf.urls.defaults import *
-from socialgraph.util import get_people_user_follows, get_people_following_user
-from socialgraph.util import get_mutual_followers
urlpatterns = patterns('socialgraph.views',
url(
r'^followers/(?P<username>[a-zA-Z0-9_-]+)/$',
'friend_list',
- {'friend_func': get_people_following_user},
+ {'list_type': 'followers'},
name='sg_followers'
),
url(
r'^following/(?P<username>[a-zA-Z0-9_-]+)/$',
'friend_list',
- {'friend_func': get_people_user_follows},
+ {'list_type': 'following'},
name='sg_following'
),
url(
r'^mutual/(?P<username>[a-zA-Z0-9_-]+)/$',
'friend_list',
- {'friend_func': get_mutual_followers},
+ {'list_type': 'mutual'},
name='sg_mutual'
),
url(
@@ -31,4 +29,9 @@
'unfollow',
name='sg_unfollow'
),
+ url(
+ r'^find-and-add/$',
+ 'find_and_add',
+ name='sg_find_add'
+ ),
)
View
43 socialgraph/views.py
@@ -5,6 +5,9 @@
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from socialgraph.models import UserLink
+from socialgraph.util import get_people_user_follows, get_people_following_user
+from socialgraph.util import get_mutual_followers
+from socialgraph.forms import SearchForm
def _get_next(request):
"""
@@ -17,13 +20,21 @@ def _get_next(request):
"""
return request.POST.get('next', request.GET.get('next', request.META.get('HTTP_REFERER', None)))
-def friend_list(request, username, friend_func=None):
+FRIEND_FUNCTION_MAP = {
+ 'followers': get_people_user_follows,
+ 'following': get_people_following_user,
+ 'mutual': get_mutual_followers,
+}
+
+def friend_list(request, list_type, username):
user = get_object_or_404(User, username=username)
- if friend_func is None:
- raise Http404
+ context = {
+ 'list_type': list_type,
+ 'friends': FRIEND_FUNCTION_MAP[list_type](user),
+ }
return render_to_response(
'socialgraph/friend_list.html',
- {'friends': friend_func(user)},
+ context,
context_instance = RequestContext(request)
)
@@ -69,4 +80,26 @@ def unfollow(request, username):
context,
context_instance = RequestContext(request)
)
-unfollow = login_required(unfollow)
+unfollow = login_required(unfollow)
+
+def find_and_add(request):
+ search_form = SearchForm(request.GET or None)
+ context = {
+ 'search_form': search_form,
+ }
+ if search_form.is_valid():
+ q = search_form.cleaned_data['q']
+ context['q'] = q
+ users = User.objects.filter(username__icontains=q) | User.objects.filter(
+ email__icontains=q)
+ else:
+ users = []
+ friends = get_people_user_follows(request.user)
+ users = [(u, u in friends) for u in users]
+ context['users'] = users
+ context['user_count'] = len(users)
+ return render_to_response(
+ 'socialgraph/find_add.html',
+ context,
+ context_instance = RequestContext(request)
+ )
View
19 templates/base.html
@@ -16,15 +16,23 @@
<ul id="nav">
<li><a href="{% url ev_tonight %}">Tonight</a></li>
<li><a href="{% url ev_archive %}">Archive</a></li>
- <li><span>Everyone</span>
- <ul id="subnav_everyone">
+ <li><span class="subnav_everyone">Everyone</span>
+ <ul class="subnav_everyone">
<li><a href="{% url ev_everyone_tonight %}">Tonight</a></li>
<li><a href="{% url ev_everyone_archive %}">Archive</a></li>
</ul>
</li>
{% if user.is_authenticated %}
+ <li><span class="subnav_friends">Friends</span>
+ <ul class="subnav_friends">
+ <li><a href="{% url sg_find_add %}">Find and Add Friends</a></li>
+ <li><a href="{% url sg_followers user.username %}">People You Follow</a></li>
+ <li><a href="{% url sg_following user.username %}">People Following You</a></li>
+ <li><a href="{% url sg_mutual user.username %}">Mutual Friends</a></li>
+ </ul>
+ </li>
+ <li><a href="{% url auth_password_change %}">Settings</a></li>
<li><a href="{% url auth_logout %}">Logout</a></li>
- <li><a href="{% url auth_password_change %}">Change Password</a></li>
{% else %}
<li><a href="{% url auth_login %}">Login</a></li>
<li><a href="{% url registration_register %}">Register</a></li>
@@ -57,6 +65,9 @@
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.form.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.livequery.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/global.js"></script>
+ <!--[if lt IE 7]>
+ <script type="text/javascript" src="{{ MEDIA_URL }}js/unitpngfix.js"></script>
+ <![endif]-->
{% block extra_body %}{% endblock %}
</body>
-</html>
+</html>
View
2 templates/events/archive.html
@@ -18,4 +18,4 @@
{% else %}
<p>There are no events listed.</p>
{% endif %}
-{% endblock %}
+{% endblock %}
View
12 templates/events/event_details.html
@@ -8,7 +8,13 @@ <h2 id="event_title">Event</h2>
<div class="clear"></div>
{% event event 1 %}
<h2 id="attendees_title">Attendees</h2>
- {% for person in event.attendees.all %}
- {% person person %}
- {% endfor %}
+ {% with event.attendees.all as attendees %}
+ {% ifequal attendees.count 0 %}
+ <p>No attendees listed</p>
+ {% else %}
+ {% for person in event.attendees.all %}
+ {% person person %}
+ {% endfor %}
+ {% endifequal %}
+ {% endwith %}
{% endblock %}
View
2 templates/events/tonight.html
@@ -45,4 +45,4 @@ <h2 id="all_events_title">All Events</h2>
{% else %}
<p>There are no events listed.</p>
{% endif %}
-{% endblock %}
+{% endblock %}
View
4 templates/misc/settings.html
@@ -0,0 +1,4 @@
+{% extends "base.html" %}
+
+{% block main_content %}
+{% endblock %}
View
57 templates/profile/detail.html
@@ -0,0 +1,57 @@
+{% extends "base.html" %}
+{% load profile_tags %}
+{% load events_tags %}
+
+{% block main_content %}
+ <h1>Details for User: {{ profile_user.username }}</h1>
+ <div class="follow">
+ {% person profile_user %}
+ {% ifnotequal profile_user user %}
+ <form method="POST" action="{% if friend %}{% url sg_unfollow profile_user.username %}{% else %}{% url sg_follow profile_user.username %}{% endif %}">
+ <input type="submit" value="{% if friend %}Unfollow{% else %}Follow{% endif %}" />
+ </form>
+ {% endifnotequal %}
+ </div>
+ <div class="clear"></div>
+
+ <h2>People who Follow {{ profile_user.username }}: </h2>
+ {% ifequal people_following_user.count 0 %}
+ <p>Nobody yet.</p>
+ {% else %}
+ {% for person in people_following_user %}
+ {% person person %}
+ {% endfor %}
+ {% endifequal %}
+ <div class="clear"></div>
+
+ <h2>People who {{ profile_user.username }} Follows: </h2>
+ {% ifequal people_user_follows.count 0 %}
+ <p>Nobody yet.</p>
+ {% else %}
+ {% for person in people_user_follows %}
+ {% person person %}
+ {% endfor %}
+ {% endifequal %}
+ <div class="clear"></div>
+
+ <h2>Mutual Followers</h2>
+ {% ifequal mutual_followers.count 0 %}
+ <p>Nobody yet.</p>
+ {% else %}
+ {% for person in mutual_followers %}
+ {% person person %}
+ {% endfor %}
+ {% endifequal %}
+ <div class="clear"></div>
+
+ <h2>Last {{ num_events_created }} Event{{ num_events_created|pluralize }} Created by {{ profile_user.username }}</h2>
+ {% for event in events_created %}
+ {% event event counter.get_int %}
+ {% endfor %}
+ <div class="clear"></div>
+
+ <h2>Last {{ num_events_attended }} Event{{ num_events_attended|pluralize }} Attended by {{ profile_user.username }}</h2>
+ {% for event in events_attended %}
+ {% event event counter.get_int %}
+ {% endfor %}
+{% endblock %}
View
2 templates/profile/person.html
@@ -1,7 +1,7 @@
{% load gravatar %}
{% load events_tags %}
<div class="person">
- <a href="">
+ <a href="{% url profile_detail user.username %}">
<span class="username">{{ user.username|truncate:"12" }}</span>
{% gravatar user 58 %}
</a>
View
BIN templates/registration/.registration_form.html.swp
Binary file not shown.
View
2 templates/registration/activate.html
@@ -8,4 +8,4 @@
{% else %}
<p class="failure">We could not activate your account. Please make sure that you have clicked the correct link in your e-mail or typed in the correct address. If you get this message repeatedly, <a href="mailto:floguy@gmail.com">contact us</a> so that we can set your account up correctly.</p>
{% endif %}
-{% endblock %}
+{% endblock %}
View
4 templates/registration/login.html
@@ -9,7 +9,7 @@
<li>If you still have troubles loogging in, maybe you haven&rsquo;t activated your account. Check your e-mail and look for an activation key, or <a href="{% url registration_resend_activation %}">have it re-sent to you</a>.</li>
</ul>
{% endif %}
- <form method="POST" action="">
+ <form method="POST" class="standard" action="">
<ul>
<li><label for="id_username">Username: </label>{{ form.username }}</li>
<li><label for="id_password">Password: </label>{{ form.password }}</li>
@@ -19,4 +19,4 @@
</form>
<p>Not yet registered? <a href="{% url registration_register %}">Register now</a> to become a member of the site!</p>
<p>Can&rsquo;t remember your password? <a href="{% url auth_password_reset %}">Click here</a> to generate a new one.</p>
-{% endblock %}
+{% endblock %}
View
4 templates/registration/password_change_form.html
@@ -4,7 +4,7 @@
{% block main_content %}
<p>Please enter your old password, for security&rsquo;s sake, and then enter your new password twice so we can verify you typed it in correctly.</p>
- <form method="POST" action="">
+ <form method="POST" class="standard" action="">
<ul>
{% if form.old_password.errors %}{{ form.old_password.html_error_list }}{% endif %}
<li><label for="id_old_password">Old password: </label>{{ form.old_password }}</li>
@@ -15,4 +15,4 @@
</ul>
<input type="submit" value="Change my password" />
</form>
-{% endblock %}
+{% endblock %}
View
4 templates/registration/password_reset_form.html
@@ -5,10 +5,10 @@
{% block main_content %}
<p>Forgotten your password? Enter your e-mail address below, and we&rsquo;ll reset your password and e-mail the new one to you.</p>
{{ form.email.errors }}
- <form method="POST" action="">
+ <form method="POST" class="standard" action="">
<ul>
<li><label for="id_email">E-mail address: </label> {{ form.email }} </li>
</ul>
<input type="submit" value="Reset my password" />
</form>
-{% endblock %}
+{% endblock %}
View
4 templates/registration/registration_form.html
@@ -3,10 +3,10 @@
{% block title %}Register for an Account - {{ block.super }}{% endblock %}
{% block main_content %}
- <form method="POST" action="">
+ <form method="POST" class="standard" action="">
<ul>
{{ form.as_ul }}
</ul>
<input type="submit" value="Register" />
</form>
-{% endblock %}
+{% endblock %}
View
29 templates/socialgraph/find_add.html
@@ -0,0 +1,29 @@
+{% extends "base.html" %}
+{% load profile_tags %}
+
+{% block main_content %}
+ <form class="standard" method="GET">
+ <ul>
+ <li><label for="id_q">Search for your friend&rsquo;s name or e-mail address: </label>
+ {{ search_form.q }}</li>
+ </ul>
+ <input type="submit" value="User Search">
+ </form>
+ {% if q %}
+ <h1>Results</h1>
+ {% ifequal user_count 0 %}
+ <p>No results for the given query</p>
+ {% else %}
+ {% for person, friend in users %}
+ <div class="follow">
+ {% person person %}
+ {% ifnotequal person user %}
+ <form method="POST" action="{% if friend %}{% url sg_unfollow person.username %}{% else %}{% url sg_follow person.username %}{% endif %}">
+ <input type="submit" value="{% if friend %}Unfollow{% else %}Follow{% endif %}" />
+ </form>
+ {% endifnotequal %}
+ </div>
+ {% endfor %}
+ {% endifequal %}
+ {% endif %}
+{% endblock %}
View
23 templates/socialgraph/friend_list.html
@@ -1,10 +1,21 @@
{% extends "base.html" %}
-{% load pagination_tags %}
+{% load profile_tags %}
{% block main_content %}
- {% autopaginate friends %}
- {% for friend in friends %}
- <p>{{ friend }}</p>
- {% endfor %}
- {% paginate %}
+ {% ifequal list_type "followers" %}
+ <h1>People Who You Follow:</h1>
+ {% else %}
+ {% ifequal list_type "following" %}
+ <h1>People Following You:</h1>
+ {% else %}
+ <h1>People Who You Follow, Who Also Follow You:</h1>
+ {% endifequal %}
+ {% endifequal %}
+ {% ifequal friends.count 0 %}
+ <p>No friends listed</p>
+ {% else %}
+ {% for friend in friends %}
+ {% person friend %}
+ {% endfor %}
+ {% endifequal %}
{% endblock %}
View
1 urls.py
@@ -17,6 +17,7 @@
(r'^events/', include('events.urls')),
(r'^friends/', include('socialgraph.urls')),
(r'^accounts/', include('registration.urls')),
+ (r'^profile/', include('profile.urls')),
(r'^admin/(.*)', admin.site.root),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
)

0 comments on commit 5e18669

Please sign in to comment.