aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
Diffstat (limited to 'servo')
-rw-r--r--servo/models/calendar.py4
-rwxr-xr-xservo/templates/accounts/calendars.html58
-rwxr-xr-xservo/templates/accounts/orders.html8
-rwxr-xr-xservo/templates/accounts/tabs.html12
-rw-r--r--servo/templates/accounts/updates.html2
-rwxr-xr-xservo/templates/accounts/view_calendar.html6
-rw-r--r--servo/templates/checkin/index.html2
-rwxr-xr-xservo/templates/default.html14
-rwxr-xr-xservo/templates/search/spotlight.html2
-rw-r--r--servo/urls/default.py2
-rw-r--r--servo/views/account.py57
-rw-r--r--servo/views/order.py3
12 files changed, 84 insertions, 86 deletions
diff --git a/servo/models/calendar.py b/servo/models/calendar.py
index b88faae..e7bf15f 100644
--- a/servo/models/calendar.py
+++ b/servo/models/calendar.py
@@ -28,7 +28,7 @@ class Calendar(models.Model):
hours_per_day = models.FloatField(
null=True,
blank=True,
- verbose_name=_("hours per day"),
+ verbose_name=_("Hours per day"),
help_text=_("How many hours per day should be in this calendar")
)
@@ -77,7 +77,7 @@ class Calendar(models.Model):
return math.ceil(total/3600.0)
def get_absolute_url(self):
- return reverse('calendars.view', args=[self.user.username, self.pk])
+ return reverse('calendars.view', args=[self.pk])
class Meta:
app_label = "servo"
diff --git a/servo/templates/accounts/calendars.html b/servo/templates/accounts/calendars.html
index c10276c..72a83f9 100755
--- a/servo/templates/accounts/calendars.html
+++ b/servo/templates/accounts/calendars.html
@@ -4,26 +4,26 @@
{% block toolbar %}
<div class="btn-group">
- <a href="{% url 'calendars-create' username=request.user.username %}" data-modal="#modal" class="btn"><i class="icon-plus"></i> {% trans "New Calendar" %}</a>
-{% if calendar %}
- <a href="{% url 'calendars.event.edit' username=request.user.username cal_pk=calendar.pk %}" class="btn">{% trans "New Event" %}</a>
-{% endif %}
+ <a href="{% url 'calendars-create' %}" data-modal="#modal" class="btn"><i class="icon-plus"></i> {% trans "New Calendar" %}</a>
+ {% if calendar %}
+ <a href="{% url 'calendars.event.edit' cal_pk=calendar.pk %}" class="btn">{% trans "New Event" %}</a>
+ {% endif %}
</div>
<div class="btn-group">
-{% if calendar %}
- <a href="print/" class="btn window"><i class="icon-print"></i> {% trans "Print" %}</a>
- <a href="{% url 'calendars-edit' request.user.username calendar.pk view %}" data-modal="#modal" class="btn"><i class="icon-pencil"></i> {% trans "Edit" %}</a>
- {% if perms.servo.delete_calendar %}
- <a href="{{ calendar.get_absolute_url }}delete/" data-modal="#modal" class="btn"><i class="icon-trash"></i> {% trans "Delete" %}</a>
- {% else %}
- <a href="" class="btn disabled">{% trans "Delete" %}</a>
- {% endif %}
-{% endif %}
+ {% if calendar %}
+ <a href="print/" class="btn window"><i class="icon-print"></i> {% trans "Print" %}</a>
+ <a href="{% url 'calendars-edit' calendar.pk view %}" data-modal="#modal" class="btn"><i class="icon-pencil"></i> {% trans "Edit" %}</a>
+ {% if perms.servo.delete_calendar %}
+ <a href="{{ calendar.get_absolute_url }}delete/" data-modal="#modal" class="btn"><i class="icon-trash"></i> {% trans "Delete" %}</a>
+ {% else %}
+ <a href="" class="btn disabled">{% trans "Delete" %}</a>
+ {% endif %}
+ {% endif %}
</div>
<div class="btn-group">
- <a href="download/" class="btn {% if not calendar %}disabled{% endif %}"><i class="icon-download"></i> {% trans "Download" %}</a>
+ <a href="download/" class="btn {% if not calendar %}disabled{% endif %}"><i class="icon-download"></i> {% trans "Download" %}</a>
</div>
{% endblock toolbar %}
@@ -31,25 +31,25 @@
{% block second_row %}
<div class="row-fluid">
- <div class="span3">
- <ul class="nav nav-list">
- <li class="nav-header">{% trans "Calendars" %}</li>
- {% for c in calendars %}
- <li class="{% active request c.pk '/' %}">
- <a href="{% url 'calendars.view' pk=c.pk username=request.user.username view='week' %}">{{ c.title }}<span class="badge pull-right">{{ c.get_unfinished_count }}</span></a>
- </li>
- {% endfor %}
- </ul>
- </div>
-
- <div class="span9">
+ <div class="span3">
+ <ul class="nav nav-list">
+ <li class="nav-header">{% trans "Calendars" %}</li>
+ {% for c in calendars %}
+ <li class="{% active request c.pk '/' %}">
+ <a href="{% url 'calendars.view' pk=c.pk view='week' %}">{{ c.title }}<span class="badge pull-right">{{ c.get_unfinished_count }}</span></a>
+ </li>
+ {% endfor %}
+ </ul>
+ </div>
+
+ <div class="span9">
{% block detail_view %}
- <h1 class="muted text-center">{% trans "No calendar selected" %}</h1>
+ <h1 class="muted text-center">{% trans "No calendar selected" %}</h1>
{% endblock detail_view %}
- </div>
+ </div>
</div>
{% endblock second_row %}
{% block crumbs %}
- <li class="active"><a href="{% url 'calendars-list' username=request.user.username %}">{% trans "Calendars" %}</a></li>
+<li class="active"><a href="{% url 'calendars-list' %}">{% trans "Calendars" %}</a></li>
{% endblock crumbs %}
diff --git a/servo/templates/accounts/orders.html b/servo/templates/accounts/orders.html
index 8420ad8..c26e07d 100755
--- a/servo/templates/accounts/orders.html
+++ b/servo/templates/accounts/orders.html
@@ -23,7 +23,7 @@
<div class="row-fluid">
<div class="span12">
- {% include "accounts/tabs.html" %}
+ {% include "accounts/tabs.html" %}
</div>
</div>
@@ -32,15 +32,15 @@
<div id="collapsable" class="collapse out">
<div class="well clearfix">
<form action="" method="get" class="form-inline">
- {% for field in form %}
+ {% for field in form %}
<div class="control-group pull-left">
<label class="control-label">{{ field.label }}</label>
<div class="controls">{{ field }}</div>
</div>
- {% endfor %}
+ {% endfor %}
<p class="clearfix"><hr/></p>
<div class="pull-right">
- <a class="btn" href="{% url 'accounts-list_orders' username=request.user.username %}?user=state=1&amp;user={{ request.user.pk }}"><i class="icon-refresh"></i> {% trans "Reset" %}</a>
+ <a class="btn" href="{% url 'accounts-list_orders' %}?user=state=1&amp;user={{ request.user.pk }}"><i class="icon-refresh"></i> {% trans "Reset" %}</a>
<button class="btn btn-primary" type="submit"><i class="icon-search icon-white"></i> {% trans "Search" %}</button>
</div>
</form>
diff --git a/servo/templates/accounts/tabs.html b/servo/templates/accounts/tabs.html
index 4444ab8..e570241 100755
--- a/servo/templates/accounts/tabs.html
+++ b/servo/templates/accounts/tabs.html
@@ -2,21 +2,19 @@
{% load servo_tags %}
<ul class="nav nav-tabs">
-{% with request.user.username as username %}
<li class="{% active request "orders" %}">
- <a href="{% url 'accounts-list_orders' username=username %}">{% trans "Orders" %}</a>
+ <a href="{% url 'accounts-list_orders' %}">{% trans "Orders" %}</a>
</li>
<li class="{% active request "updates" %}">
- <a href="{% url 'accounts-updates' username=username %}">{% trans "Updates" %}</a>
+ <a href="{% url 'accounts-updates' %}">{% trans "Updates" %}</a>
</li>
<li class="{% active request "calendars" %}">
- <a href="{% url 'calendars-list' username=username %}">{% trans "Calendars" %}</a>
+ <a href="{% url 'calendars-list' %}">{% trans "Calendars" %}</a>
</li>
<li class="{% active request "stats" %}">
- <a href="{% url 'accounts-stats' username=username %}">{% trans "Statistics" %}</a>
+ <a href="{% url 'accounts-stats' %}">{% trans "Statistics" %}</a>
</li>
<li class="{% active request "settings" %}">
- <a href="{% url 'accounts-settings' username=username %}">{% trans "Settings" %}</a>
+ <a href="{% url 'accounts-settings' %}">{% trans "Settings" %}</a>
</li>
-{% endwith %}
</ul>
diff --git a/servo/templates/accounts/updates.html b/servo/templates/accounts/updates.html
index 121aea9..08644ba 100644
--- a/servo/templates/accounts/updates.html
+++ b/servo/templates/accounts/updates.html
@@ -4,7 +4,7 @@
{% block toolbar %}
{% if perms.servo.add_order %}
- <a href="{% url 'accounts-clear_notifications' request.user.username %}?t={% now "Y/m/d/H/i" %}" class="btn"><i class="icon-ok"></i> {% trans "Clear all" %}</a>
+ <a href="{% url 'accounts-clear_notifications' %}?t={% now "Y/m/d/H/i" %}" class="btn"><i class="icon-ok"></i> {% trans "Clear all" %}</a>
{% endif %}
{% endblock toolbar %}
diff --git a/servo/templates/accounts/view_calendar.html b/servo/templates/accounts/view_calendar.html
index 2b063e2..7eece46 100755
--- a/servo/templates/accounts/view_calendar.html
+++ b/servo/templates/accounts/view_calendar.html
@@ -15,9 +15,9 @@
{% block browse_block %}
<div class="btn-group pull-right">
- <a href="{% url 'calendars-view_calendar' username=request.user.username pk=calendar.pk view=view start_date=previous|date:'Y-m-d' %}" class="btn"><i class="icon-chevron-left"></i></a>
+ <a href="{% url 'calendars-view_calendar' pk=calendar.pk view=view start_date=previous|date:'Y-m-d' %}" class="btn"><i class="icon-chevron-left"></i></a>
<a href="{{ base_url }}" class="btn">{% trans "Today" %}</a>
- <a href="{% url 'calendars-view_calendar' username=request.user.username pk=calendar.pk view=view start_date=next|date:'Y-m-d' %}" class="btn"><i class="icon-chevron-right"></i></a>
+ <a href="{% url 'calendars-view_calendar' pk=calendar.pk view=view start_date=next|date:'Y-m-d' %}" class="btn"><i class="icon-chevron-right"></i></a>
</div>
{% endblock browse_block %}
</div>
@@ -61,6 +61,6 @@
{% endblock detail_view %}
{% block crumbs %}
- <li><a href="{% url 'calendars-list' username=request.user.username %}">{% trans "Calendars" %}</a> <span class="divider">/</span></li>
+ <li><a href="{% url 'calendars-list' %}">{% trans "Calendars" %}</a> <span class="divider">/</span></li>
<li class="active">{{ calendar.title }}</li>
{% endblock crumbs %}
diff --git a/servo/templates/checkin/index.html b/servo/templates/checkin/index.html
index 2995be5..d7928fb 100644
--- a/servo/templates/checkin/index.html
+++ b/servo/templates/checkin/index.html
@@ -44,7 +44,7 @@
<li class="disabled"><a href="#">{% trans "No users found" %}</a></li>
{% endfor %}
<li class="divider"></li>
- <li><a href="{% url 'accounts-list_orders' user.username %}">{% bootstrap_icon "log-in" %} {% trans "Go to Servo" %}</a></li>
+ <li><a href="{% url 'accounts-list_orders' %}">{% bootstrap_icon "log-in" %} {% trans "Go to Servo" %}</a></li>
<li><a href="{% url 'accounts-logout' %}" data-modal="#modal">{% bootstrap_icon "off" %} {% trans "Log out" %}...</a></li>
</ul>
</li>
diff --git a/servo/templates/default.html b/servo/templates/default.html
index 922d567..adcc592 100755
--- a/servo/templates/default.html
+++ b/servo/templates/default.html
@@ -31,7 +31,7 @@
</a>
<div class="nav-collapse collapse">
<ul class="nav">
- <li class="{% active request request.user.username %}"><a href="{% url 'accounts-list_orders' request.user.username %}" title="{% trans "Homepage" %}"><i class="icon-home icon-white"></i></a></li>
+ <li class="{% active request request.user.username %}"><a href="{% url 'accounts-list_orders' %}" title="{% trans "Homepage" %}"><i class="icon-home icon-white"></i></a></li>
<li class="{% active request '^orders' %}"><a href="{% url 'orders-index' %}?page=1"><i class="icon-inbox icon-white"></i> {% trans "Orders" %}</a></li>
<li class="{% active request '^sales' %}"><a href="{% url 'products-list_products' %}"><i class="icon-shopping-cart icon-white"></i> {% trans "Inventory" %}</a></li>
<li class="{% active request '^devices' %}"><a href="{% url 'devices-list' %}"><i class="icon-hdd icon-white"></i> {% trans "Devices" %}</a></li>
@@ -65,9 +65,9 @@
<ul class="dropdown-menu">
<li><a href="#"><i class="icon-user"></i> {{ request.user.get_name }}</a></li>
<li class="divider"></li>
- <li><a href="{% url 'accounts-list_orders' user.username %}"><i class="icon-home"></i> {% trans "Homepage" %}</a></li>
- <li><a href="{% url 'calendars-list' user.username %}"><i class="icon-calendar"></i> {% trans "Calendars" %}</a></li>
- <li><a href="{% url 'accounts-settings' user.username %}"><i class="icon-wrench"></i> {% trans "Profile" %}</a></li>
+ <li><a href="{% url 'accounts-list_orders' %}"><i class="icon-home"></i> {% trans "Homepage" %}</a></li>
+ <li><a href="{% url 'calendars-list' %}"><i class="icon-calendar"></i> {% trans "Calendars" %}</a></li>
+ <li><a href="{% url 'accounts-settings' %}"><i class="icon-wrench"></i> {% trans "Profile" %}</a></li>
{% if request.user.is_staff %}
<li><a href="{% url 'admin-settings' %}"><i class="icon-cog"></i> {% trans "System Settings" %}</a></li>
{% endif %}
@@ -104,7 +104,7 @@
{% endfor %}
<li class="divider"></li>
<li>
- <a class="text-center" href="{% url 'accounts-updates' request.user.username %}?kind=set_status">
+ <a class="text-center" href="{% url 'accounts-updates' %}?kind=set_status">
<strong>{% trans "See All Alerts" %}</strong> <i class="icon-chevron-right"></i>
</a>
</li>
@@ -138,7 +138,7 @@
{% endwith %}
<li class="divider"></li>
<li>
- <a class="text-center" href="{% url 'accounts-updates' request.user.username %}?kind=note_added">
+ <a class="text-center" href="{% url 'accounts-updates' %}?kind=note_added">
<strong>{% trans "Read All Messages" %}</strong> <i class="icon-chevron-right"></i>
</a>
</li>
@@ -165,7 +165,7 @@
<div class="footer">
<div class="container-fluid">
<ul class="breadcrumb pull-left">
- <li><i class="icon-home"></i> <a href="{% url 'accounts-list_orders' request.user.username %}">{{ request.user.get_full_name }}</a> <span class="divider">/</span></li>
+ <li><i class="icon-home"></i> <a href="{% url 'accounts-list_orders' %}">{{ request.user.get_full_name }}</a> <span class="divider">/</span></li>
{% block crumbs %}{% endblock crumbs %}
</ul>
<small class="copyright pull-right muted">&copy; {% now "Y" %} First Party Software | <a href="https://docs.servoapp.com/terms/" target="_blank">{% trans "Terms" %}</a></small>
diff --git a/servo/templates/search/spotlight.html b/servo/templates/search/spotlight.html
index e372b23..3b3715c 100755
--- a/servo/templates/search/spotlight.html
+++ b/servo/templates/search/spotlight.html
@@ -33,5 +33,5 @@
{% endblock second_column %}
{% block footer %}
- <li><i class="icon-home"></i> <a href="{% url 'accounts-list_orders' request.user.username %}">{% trans "Home" %}</a> <span class="divider">/</span></li><li class="active">{{ title }}</li>
+ <li><i class="icon-home"></i> <a href="{% url 'accounts-list_orders' %}">{% trans "Home" %}</a> <span class="divider">/</span></li><li class="active">{{ title }}</li>
{% endblock footer %}
diff --git a/servo/urls/default.py b/servo/urls/default.py
index a8be378..35c1f05 100644
--- a/servo/urls/default.py
+++ b/servo/urls/default.py
@@ -48,6 +48,6 @@ urlpatterns = patterns(
(r'^api/', include('servo.urls.api')),
(r'^kaboom/$', 'servo.views.error.report'),
- url(r'^(?P<username>[\w@\+\-\._]+)/', include('servo.urls.account')),
+ url(r'^home/', include('servo.urls.account')),
)
diff --git a/servo/views/account.py b/servo/views/account.py
index a85892b..8c782d1 100644
--- a/servo/views/account.py
+++ b/servo/views/account.py
@@ -23,7 +23,7 @@ from servo.models import Order, User, Calendar, CalendarEvent
from servo.forms.account import ProfileForm, RegistrationForm, LoginForm
-def settings(request, username):
+def settings(request):
"""
User editing their profile preferences
"""
@@ -48,7 +48,7 @@ def settings(request, username):
request.session[translation.LANGUAGE_SESSION_KEY] = lang
request.session['django_timezone'] = user.timezone
- return redirect(settings, username)
+ return redirect(settings)
else:
print("Error in user settings: %s" % form.errors)
messages.error(request, _("Error in user details"))
@@ -56,7 +56,7 @@ def settings(request, username):
return render(request, "accounts/settings.html", locals())
-def orders(request, username):
+def orders(request):
"""
This is basically like orders/index, but limited to the user
First, filter by the provided search criteria,
@@ -118,7 +118,7 @@ def login(request):
if request.GET.get('next'):
return redirect(request.GET['next'])
else:
- return redirect(orders, username=user.username)
+ return redirect(orders)
else:
messages.error(request, _("Invalid input for login"))
@@ -136,13 +136,13 @@ def logout(request):
@permission_required("servo.add_calendar")
-def calendars(request, username=None):
+def calendars(request):
data = {'title': _('Calendars')}
data['calendars'] = Calendar.objects.filter(user=request.user)
if data['calendars'].count() > 0:
cal = data['calendars'][0]
- return redirect(view_calendar, username, cal.pk)
+ return redirect(view_calendar, cal.pk)
return render(request, "accounts/calendars.html", data)
@@ -193,7 +193,7 @@ def prepare_calendar_view(request, pk, view, start_date):
@permission_required("servo.add_calendar")
-def download_calendar(request, username, pk, view):
+def download_calendar(request, pk, view):
calendar = Calendar.objects.get(pk=pk)
response = HttpResponse(content_type="text/csv")
@@ -208,7 +208,7 @@ def download_calendar(request, username, pk, view):
@permission_required("servo.add_calendar")
-def print_calendar(request, username, pk, view, start_date):
+def print_calendar(request, pk, view, start_date):
data = prepare_calendar_view(request, pk, view, start_date)
calendar = data['calendar']
@@ -220,26 +220,26 @@ def print_calendar(request, username, pk, view, start_date):
@permission_required("servo.add_calendar")
-def view_calendar(request, username, pk, view, start_date=None):
+def view_calendar(request, pk, view, start_date=None):
data = prepare_calendar_view(request, pk, view, start_date)
- data['base_url'] = reverse(view_calendar, args=[username, pk, view])
+ data['base_url'] = reverse(view_calendar, args=[pk, view])
return render(request, "accounts/view_calendar.html", data)
@permission_required("servo.delete_calendar")
-def delete_calendar(request, username, pk):
+def delete_calendar(request, pk):
calendar = Calendar.objects.get(pk=pk)
if calendar.user != request.user:
messages.error(request, _("Users can only delete their own calendars!"))
- return redirect(calendars, username=username)
+ return redirect(calendars)
if request.method == "POST":
calendar.delete()
messages.success(request, _('Calendar deleted'))
- return redirect(calendars, username=request.user.username)
+ return redirect(calendars)
data = {'title': _("Really delete this calendar?")}
data['action'] = request.path
@@ -248,7 +248,7 @@ def delete_calendar(request, username, pk):
@permission_required("servo.change_calendar")
-def edit_calendar(request, username, pk=None, view="week"):
+def edit_calendar(request, pk=None, view="week"):
from servo.models.calendar import CalendarForm
calendar = Calendar(user=request.user)
@@ -261,7 +261,7 @@ def edit_calendar(request, username, pk=None, view="week"):
if form.is_valid():
calendar = form.save()
messages.success(request, _("Calendar saved"))
- return redirect(view_calendar, username, calendar.pk, 'week')
+ return redirect(view_calendar, calendar.pk, 'week')
form = CalendarForm(instance=calendar)
@@ -273,7 +273,7 @@ def edit_calendar(request, username, pk=None, view="week"):
@permission_required('servo.change_calendar')
-def edit_calendar_event(request, username, cal_pk, pk=None):
+def edit_calendar_event(request, cal_pk, pk=None):
from servo.models.calendar import CalendarEventForm
calendar = Calendar.objects.get(pk=cal_pk)
@@ -304,22 +304,21 @@ def edit_calendar_event(request, username, cal_pk, pk=None):
@permission_required("servo.change_calendar")
-def finish_calendar_event(request, username, cal_pk, pk):
+def finish_calendar_event(request, cal_pk, pk):
event = CalendarEvent.objects.get(pk=pk)
event.set_finished()
messages.success(request, _(u'Calendar event updated'))
- return redirect(view_calendar, username, cal_pk, 'week')
+ return redirect(view_calendar, cal_pk, 'week')
-def delete_calendar_event(request, username, cal_pk, pk):
- if username != request.user.username:
- messages.error(request, _(u'Users can only delete their own events!'))
-
- return redirect(calendars, username=request.user.username)
-
+def delete_calendar_event(request, cal_pk, pk):
event = CalendarEvent.objects.get(pk=pk)
+ if event.user != request.user:
+ messages.error(request, _(u'Users can only delete their own events!'))
+ return redirect(calendars)
+
if request.method == 'POST':
event.delete()
messages.success(request, _('Calendar event deleted'))
@@ -357,7 +356,7 @@ def register(request):
return render(request, 'accounts/register.html', data)
-def clear_notifications(request, username):
+def clear_notifications(request):
from datetime import datetime
ts = [int(x) for x in request.GET.get('t').split('/')]
ts = datetime(*ts, tzinfo=timezone.get_current_timezone())
@@ -367,7 +366,7 @@ def clear_notifications(request, username):
return redirect(request.META['HTTP_REFERER'])
-def search(request, username):
+def search(request):
"""
User searching for something from their homepage
"""
@@ -375,7 +374,7 @@ def search(request, username):
if not query or len(query) < 3:
messages.error(request, _('Search query is too short'))
- return redirect('accounts-list_orders', username)
+ return redirect('accounts-list_orders')
request.session['search_query'] = query
@@ -397,7 +396,7 @@ def search(request, username):
return render(request, "accounts/orders.html", data)
-def stats(request, username):
+def stats(request):
from servo.views.stats import prep_view, BasicStatsForm
data = prep_view(request)
form = BasicStatsForm(initial=data['initial'])
@@ -409,7 +408,7 @@ def stats(request, username):
return render(request, "accounts/stats.html", data)
-def updates(request, username):
+def updates(request):
title = _('Updates')
kind = request.GET.get('kind', 'note_added')
events = request.user.notifications.filter(action=kind)
diff --git a/servo/views/order.py b/servo/views/order.py
index 80e0077..3c284fb 100644
--- a/servo/views/order.py
+++ b/servo/views/order.py
@@ -3,6 +3,8 @@
import json
from gsxws.core import GsxError
+from datetime import datetime, timedelta
+
from django.http import QueryDict
from django.db.models import Q
@@ -64,7 +66,6 @@ def prepare_list_view(request, args):
orders = orders.filter(created_at__range=[start_date, end_date])
if args.get("status_older_than"):
- from datetime import datetime, timedelta
days = int(args.get("status_older_than"))
limit = datetime.now() - timedelta(days=days)
orders = orders.filter(status_started_at__lt=limit)