Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple fixes for hnofficehours #28

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ settings_local.py
*.sqlite3
pip-log.txt
*.pyc
*~
5 changes: 3 additions & 2 deletions apps/profiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tagging.fields import TagField
from tagging.models import Tag
from tagging_autocomplete.models import TagAutocompleteField
from timezones.zones import PRETTY_TIMEZONE_CHOICES
from timezones.fields import TimeZoneField

class Profile(models.Model):
Expand All @@ -13,8 +14,8 @@ class Profile(models.Model):
gchat = models.CharField("Google Chat", max_length=20, null=True, blank=True)
phone = models.CharField("Phone number", max_length=20, null=True, blank=True)
is_available = models.BooleanField("Available now")
timezone = TimeZoneField()

timezone = TimeZoneField(choices=sorted(PRETTY_TIMEZONE_CHOICES,
key=lambda x: (int(x[1][4:9]), x[1])))
skills = models.ManyToManyField('Skill', blank=True)
def __unicode__(self):
return unicode(self.user)
Expand Down
4 changes: 2 additions & 2 deletions apps/profiles/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
name='ajax_toggle_availability'),
url(r'^set_availability/(?P<set_status>\d)/$', 'set_availability',
name='set_availability'),
url(r'^skills/(?P<skill>\w+)/$', 'list_profiles_by_skill',
url(r'^skills/(?P<skill>[-.\w]+)/$', 'list_profiles_by_skill',
name='list_profiles_by_skill'),
url(r'^(?P<username>\w+)/$', 'view_profile', name='view_profile'),
url(r'^(?P<username>[-.\w]+)/$', 'view_profile', name='view_profile'),
url(r'^(?P<profile_id>\d+)/skill/(?P<skill_id>\d+)/(?P<verb>\w+)/$', 'ajax_view', name='ajax-view'),
)
4 changes: 2 additions & 2 deletions apps/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def search(request):
try:
qs = [list(chain(*[skill.profile_set.all() for skill in Skill.objects.filter(name__contains=tag_clean(qry))])) for qry in query_list]
results = list(set(qs[0]).intersection(*qs))
except Exception as e:
except Exception, e:
results = None
else:
try:
results = list(chain(Skill.objects.get(name__contains=query_list[0]).profile_set.all()))
except Exception as e:
except Exception, e:
if e.__class__ == Skill.MultipleObjectsReturned:
results = list(chain(*[skill.profile_set.all() for skill in Skill.objects.filter(name__contains=query_list[0])]))
else:
Expand Down
Empty file modified manage.py
100644 → 100755
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions media/schedule/css/jquery.tooltip.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#tooltip {
position: absolute;
z-index: 3000;
border: 1px solid #111;
background-color: #eee;
padding: 5px;
opacity: 0.85;
}
#tooltip h3, #tooltip div { margin: 0; }
2 changes: 1 addition & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
# Uncomment the next line to enable the admin:
'django.contrib.admin',

# third-party apps:
# third-party apps: (see deploy/requirements.txt)
'ajax_select',
'django_extensions',
'schedule',
Expand Down
2 changes: 1 addition & 1 deletion settings_local.copy
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ INSTALLED_APPS = (
# Uncomment the next line to enable the admin:
'django.contrib.admin',

# third-party apps:
# third-party apps: (see deploy/requirements.txt)
'ajax_select',
'django_extensions',
'schedule',
Expand Down
4 changes: 3 additions & 1 deletion templates/profiles/view_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ <h1>
</h1>
{% if display_full_profile %}
{% with user.get_profile as profile %}
<p><label>hn profile:</label> <a
href="http://news.ycombinator.com/user?id={{ user.username }}">{{ user.username }}</a></p>
<p><label>skype:</label> {{ profile.skype }}
{% if profile.skype %}
<a class="skype" href="skype:{{ profile.skype }}?call"><img src="http://mystatus.skype.com/bigclassic/{{ profile.skype }}" style="border: none;" width="182" height="44" alt="My status" /></a>
Expand All @@ -40,7 +42,7 @@ <h2>Holds office hours for:</h2>
{% for skill in user.get_profile.skills.all %}
<li>{{ skill }}</li>
{% empty %}
<li>{{ user.username }} has not listed his skills</li>
<li>{{ user.username }} has not listed any skills</li>
{% endfor %}
</ul>
<br />
Expand Down
12 changes: 10 additions & 2 deletions templates/schedule/event_form_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
$(function() {
$("#id_start_0").datepicker({
dateFormat: $.datepicker.ATOM,
changeMonth: true,
changeYear: true,
minDate: new Date(),
onSelect: function(dateText,inst){ $("#id_end_0").val(dateText); } // automagically set end to the same date
});
$("#id_end_0").datepicker({dateFormat: $.datepicker.ATOM});
$("#id_end_0").css({visibility: "hidden"});
$("#id_start_1").timePicker();
$("#id_end_1").timePicker();
$("#id_end_recurring_period").datepicker({dateFormat: $.datepicker.ATOM});
$("#id_end_recurring_period").datepicker({
dateFormat: $.datepicker.ATOM,
changeMonth: true,
changeYear: true,
minDate: new Date()
});
var oldTime = $.timePicker("#id_start_1").getTime();
$("#id_start_1").change(function() {
if ($("#id_end_1").val()) { // Only update when second input has a value.
Expand Down
8 changes: 7 additions & 1 deletion templates/upcoming_office_hour.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
<div>
{% with office_hour.event.creator as user %}
<h3><a href="{% url view_profile user.username %}"><em>{{ user.username }}</em></a></h3>
<p>From {{ office_hour.event.start }} to {{ office_hour.event.end }}</p>
{% if office_hour.start.date == office_hour.end.date %}
<p>{{ office_hour.start.date }}
from {{ office_hour.start.time }}
to {{ office_hour.end.time }}</p>
{% else %}
<p>From {{ office_hour.start }} to {{ office_hour.end }}</p>
{% endif %}
<ul class="skill"><li>{{ user.get_profile.skills.all|join:"</li><li>" }}</li></ul>
{% endwith %}
</div>
Expand Down
10 changes: 9 additions & 1 deletion views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ def site_index(request, template_name='index.html'):
users = set(list(users_available_now) + users_holding_office_hours_now)
future = Period(events=events, start=datetime.now(),
end=datetime.now() + timedelta(days=MAX_FUTURE_DAYS))
upcoming_office_hours = future.get_occurrences()
upcoming_office_hours = []
already_saw = {}
for i in future.get_occurrences():
if len(upcoming_office_hours) >= MAX_FUTURE_OFFICE_HOURS:
break
if already_saw.get(i.event.creator):
continue
upcoming_office_hours.append(i)
already_saw[i.event.creator] = 1
upcoming_office_hours = upcoming_office_hours[:MAX_FUTURE_OFFICE_HOURS]
return direct_to_template(request, template_name, locals())

Expand Down