Permalink
Browse files

complete re-org to be more pythonic

  • Loading branch information...
1 parent 32fc78c commit 2b3d5565b88c16084fa4dff10b85cc7402b1219e @peterbe peterbe committed May 9, 2012
Showing with 559 additions and 260 deletions.
  1. +1 −0 .gitignore
  2. +0 −25 apps/dates/templates/pto/home.html
  3. +5 −1 manage.py
  4. 0 { → pto}/__init__.py
  5. 0 { → pto}/apps/.gitignore
  6. 0 { → pto}/apps/__init__.py
  7. 0 { → pto}/apps/autocomplete/__init__.py
  8. 0 { → pto}/apps/autocomplete/models.py
  9. +1 −1 { → pto}/apps/autocomplete/tests.py
  10. +1 −1 { → pto}/apps/autocomplete/urls.py
  11. +3 −3 { → pto}/apps/autocomplete/views.py
  12. 0 { → pto}/apps/dates/__init__.py
  13. 0 { → pto}/apps/dates/context_processors.py
  14. 0 { → pto}/apps/dates/csv_export.py
  15. 0 { → pto}/apps/dates/decorators.py
  16. +2 −2 { → pto}/apps/dates/forms.py
  17. 0 { → pto}/apps/dates/helpers.py
  18. 0 { → pto}/apps/dates/models.py
  19. 0 { → pto}/apps/dates/templates/dates/about-calendar-url.html
  20. 0 { → pto}/apps/dates/templates/dates/duplicate-report.html
  21. 0 { → pto}/apps/dates/templates/dates/emails_sent.html
  22. 0 { → pto}/apps/dates/templates/dates/following.html
  23. 0 { → pto}/apps/dates/templates/dates/home.html
  24. 0 { → pto}/apps/dates/templates/dates/hours.html
  25. 0 { → pto}/apps/dates/templates/dates/list.html
  26. 0 { → pto}/apps/dates/templates/dates/notification.txt
  27. 0 { → pto}/apps/dates/templates/dates/notify.html
  28. 0 { → pto}/apps/dates/tests/__init__.py
  29. +2 −2 { → pto}/apps/dates/tests/test__utils.py
  30. +9 −4 { → pto}/apps/dates/tests/test_models.py
  31. +13 −7 { → pto}/apps/dates/tests/test_views.py
  32. +1 −1 { → pto}/apps/dates/urls.py
  33. 0 { → pto}/apps/dates/utils/__init__.py
  34. 0 { → pto}/apps/dates/utils/countrytotals.py
  35. 0 { → pto}/apps/dates/utils/decorators.py
  36. 0 { → pto}/apps/dates/utils/ldap_utils.py
  37. +3 −3 { → pto}/apps/dates/views.py
  38. 0 { → pto}/apps/legacy/__init__.py
  39. 0 { → pto}/apps/legacy/management/__init__.py
  40. 0 { → pto}/apps/legacy/management/commands/__init__.py
  41. 0 { → pto}/apps/legacy/management/commands/migrate_pto.py
  42. 0 { → pto}/apps/legacy/models.py
  43. 0 { → pto}/apps/mobile/__init__.py
  44. 0 { → pto}/apps/mobile/helpers.py
  45. 0 { → pto}/apps/mobile/models.py
  46. 0 { → pto}/apps/mobile/templates/mobile/appcache.html
  47. 0 { → pto}/apps/mobile/templates/mobile/base.html
  48. 0 { → pto}/apps/mobile/templates/mobile/home.html
  49. 0 { → pto}/apps/mobile/templates/mobile/homeicon.html
  50. 0 { → pto}/apps/mobile/templates/mobile/mobile.html
  51. 0 { → pto}/apps/mobile/templates/mobile/page.hours.html
  52. 0 { → pto}/apps/mobile/templates/mobile/page.left.html
  53. 0 { → pto}/apps/mobile/templates/mobile/page.login.html
  54. 0 { → pto}/apps/mobile/templates/mobile/page.logout.html
  55. 0 { → pto}/apps/mobile/templates/mobile/page.notify.html
  56. 0 { → pto}/apps/mobile/templates/mobile/page.rightnow.html
  57. 0 { → pto}/apps/mobile/templates/mobile/page.settings.html
  58. 0 { → pto}/apps/mobile/templates/mobile/page.taken.html
  59. +5 −5 { → pto}/apps/mobile/tests.py
  60. 0 { → pto}/apps/mobile/urls.py
  61. +13 −13 { → pto}/apps/mobile/views.py
  62. 0 { → pto}/apps/users/__init__.py
  63. 0 { → pto}/apps/users/admin.py
  64. 0 { → pto}/apps/users/auth/__init__.py
  65. 0 { → pto}/apps/users/auth/backends.py
  66. 0 { → pto}/apps/users/email_auth_backend.py
  67. +1 −1 { → pto}/apps/users/forms.py
  68. 0 { → pto}/apps/users/models.py
  69. 0 { → pto}/apps/users/templates/users/login.html
  70. 0 { → pto}/apps/users/templates/users/profile.html
  71. +4 −4 { → pto}/apps/users/tests.py
  72. 0 { → pto}/apps/users/urls.py
  73. 0 { → pto}/apps/users/utils/__init__.py
  74. 0 { → pto}/apps/users/utils/ldap_lookup.py
  75. 0 { → pto}/apps/users/utils/ldap_mock.py
  76. 0 { → pto}/apps/users/views.py
  77. +1 −0 pto/base/__init__.py
  78. 0 templates/.gitignore → pto/base/models.py
  79. 0 pto/base/templates/.gitignore
  80. 0 { → pto/base}/templates/404.html
  81. 0 { → pto/base}/templates/500.html
  82. 0 { → pto/base}/templates/base.html
  83. +26 −0 pto/base/templates/example_base.html
  84. +31 −0 pto/locale/en_US/LC_MESSAGES/messages.po
  85. +29 −0 pto/locale/fr/LC_MESSAGES/messages.po
  86. +32 −0 pto/locale/templates/LC_MESSAGES/messages.pot
  87. 0 { → pto}/settings/__init__.py
  88. +49 −182 { → pto}/settings/base.py
  89. +51 −0 pto/settings/local.py
  90. 0 { → pto}/settings/local.py-dist
  91. 0 { → pto}/settings/settings_local.py-dist
  92. 0 { → pto}/settings_test.py
  93. +5 −5 { → pto}/urls.py
  94. +30 −0 puppet/files/etc/httpd/conf.d/playdoh.conf
  95. +61 −0 puppet/manifests/classes/apache.pp
  96. +3 −0 puppet/manifests/classes/custom.pp
  97. +25 −0 puppet/manifests/classes/init.pp
  98. +14 −0 puppet/manifests/classes/memcached.pp
  99. +26 −0 puppet/manifests/classes/mysql.pp
  100. +39 −0 puppet/manifests/classes/playdoh.pp
  101. +34 −0 puppet/manifests/classes/python.pp
  102. +29 −0 puppet/manifests/vagrant.pp
  103. +5 −0 vagrantconfig.yaml
  104. +5 −0 vagrantconfig_local.yaml-dist
View
@@ -20,3 +20,4 @@ settings/local*
TODO
cover/
sample_data.py
+build/
@@ -1,25 +0,0 @@
-{#
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this file,
- - You can obtain one at http://mozilla.org/MPL/2.0/.
- -->
-#}
-
-{% extends "base.html" %}
-
-{% block content %}
-<section id="pto_planner">
- <p>{{ _('Mozilla PTO Planner') }}</p>
- <form id="planner" data-url="{{ calculate_pto_url }}">
- <div><label>{{ _('Hours you have available') }}</label>
- <input name="hours_avail" id="hours_avail" type="text" value="0"></div>
- <div><label>{{ _('Hours you earn per quarter') }}</label>
- <input name="per_quarter" id="per_quarter" type="text" value="5.19"></div>
- <div><label>{{ _('Start of your trip') }}</label>
- <input class="datepicker" name="start_date" id="start_date" type="text" value=""></div>
- </form>
- <p id="result">
- {{ _('Select a start date for your trip.') }}
- </p>
-</section>
-{% endblock %}
View
@@ -2,6 +2,9 @@
import os
import sys
+# Edit this if necessary or override the variable in your environment.
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pto.settings')
+
try:
# For local development in a virtualenv:
from funfactory import manage
@@ -18,7 +21,8 @@
sys.path.remove(tmp_path)
-manage.setup_environ(__file__)
+manage.setup_environ(__file__, more_pythonic=True)
if __name__ == "__main__":
+ sys.path.append(os.path.abspath('pto'))
manage.main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -7,7 +7,7 @@
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from django.utils import simplejson as json
-from users.utils.ldap_mock import MockLDAP
+from apps.users.utils.ldap_mock import MockLDAP
from mock import Mock
from nose.tools import eq_, ok_
from test_utils import TestCase
@@ -3,7 +3,7 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
from django.conf.urls.defaults import patterns, url
-import views
+from . import views
urlpatterns = patterns('',
url(r'^cities/$', views.cities, name='autocomplete.cities'),
@@ -4,9 +4,9 @@
import logging
from django import http
-from dates.decorators import json_view
-from users.models import UserProfile, User
-from users.utils import ldap_lookup
+from apps.dates.decorators import json_view
+from apps.users.models import UserProfile, User
+from apps.users.utils import ldap_lookup
@json_view
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -8,8 +8,8 @@
from django.contrib.auth.models import User
from django.core.validators import validate_email
from django import forms
-from models import Hours, Entry
-from users.models import UserProfile
+from .models import Hours, Entry
+from apps.users.models import UserProfile
import utils
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -10,7 +10,7 @@
class TestUtils(TestCase):
def test_get_weekday_dates(self):
- from dates.utils import get_weekday_dates
+ from apps.dates.utils import get_weekday_dates
d1 = datetime.date(2018, 1, 1) # a Monday
d2 = datetime.date(2018, 1, 9) # next Tuesday
dates = list(get_weekday_dates(d1, d2))
@@ -23,7 +23,7 @@ def test_get_weekday_dates(self):
eq_(dates[6].strftime('%A'), 'Tuesday')
def test_parse_datetime(self):
- from dates.utils import parse_datetime, DatetimeParseError
+ from apps.dates.utils import parse_datetime, DatetimeParseError
eq_(parse_datetime('1285041600000').year, 2010)
eq_(parse_datetime('1283140800').year, 2010)
eq_(parse_datetime('1286744467.0').year, 2010)
@@ -4,10 +4,15 @@
import datetime
from django.contrib.auth.models import User
-from dates.models import (Entry, Hours, BlacklistedUser, FollowingUser,
- FollowingIntegrityError,
- BlacklistIntegityError,
- UserKey)
+from apps.dates.models import (
+ Entry,
+ Hours,
+ BlacklistedUser,
+ FollowingUser,
+ FollowingIntegrityError,
+ BlacklistIntegityError,
+ UserKey
+)
from nose.tools import eq_, ok_
from test_utils import TestCase
@@ -15,14 +15,19 @@
from django.contrib.auth.models import User
from django.utils import simplejson as json
from django.core import mail
-from dates.models import (Entry, Hours, BlacklistedUser, FollowingUser,
- UserKey)
+from apps.dates.models import (
+ Entry,
+ Hours,
+ BlacklistedUser,
+ FollowingUser,
+ UserKey
+)
from nose.tools import eq_, ok_
from test_utils import TestCase
from mock import Mock
import ldap
-from users.utils import ldap_lookup
-from users.utils.ldap_mock import MockLDAP
+from apps.users.utils import ldap_lookup
+from apps.users.utils.ldap_mock import MockLDAP
def unicode_csv_reader(unicode_csv_data,
@@ -123,6 +128,7 @@ def test_404_page(self):
ok_('Page not found' in response.content)
def test_500_page(self):
+
root_urlconf = __import__(settings.ROOT_URLCONF,
globals(), locals(), ['urls'], -1)
# ...so that we can access the 'handler500' defined in there
@@ -840,7 +846,7 @@ def test_notify_notification_attachment(self):
email = mail.outbox[-1]
def test_get_minions(self):
- from dates.views import get_minions
+ from apps.dates.views import get_minions
gary = User.objects.create_user(
'gary', 'gary@mozilla.com'
)
@@ -1527,7 +1533,7 @@ def test_adding_a_single_day_of_zero(self):
def test_get_taken_info(self):
user = User.objects.create(username='bob')
- from dates.views import get_taken_info
+ from apps.dates.views import get_taken_info
def function():
return get_taken_info(user)
@@ -2057,7 +2063,7 @@ def test_recently_created_flash_message(self):
# visit the home page and expect there to be a flash message there
response = self.client.get(reverse('dates.home'))
ok_('class="flash"' in response.content)
- from dates.views import make_entry_title
+ from apps.dates.views import make_entry_title
ok_(make_entry_title(entry, entry.user)[:10] in response.content)
# do it again
@@ -3,7 +3,7 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.
from django.conf.urls.defaults import patterns, url
-import views
+from . import views
urlpatterns = patterns('',
url(r'^$', views.home, name='dates.home'),
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -25,9 +25,9 @@
from django.core.cache import cache
from django.db.models import Min, Count
import vobject
-from models import Entry, Hours, BlacklistedUser, FollowingUser, UserKey
-from users.models import UserProfile, User
-from users.utils import ldap_lookup
+from .models import Entry, Hours, BlacklistedUser, FollowingUser, UserKey
+from apps.users.models import UserProfile, User
+from apps.users.utils import ldap_lookup
from .utils import parse_datetime, DatetimeParseError
from .utils.countrytotals import UnrecognizedCountryError, get_country_totals
import utils
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -10,8 +10,8 @@
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.utils import simplejson as json
-from dates.tests.test_views import ViewsTestMixin
-from dates.models import Entry, Hours
+from apps.dates.tests.test_views import ViewsTestMixin
+from apps.dates.models import Entry, Hours
from test_utils import TestCase
@@ -177,7 +177,7 @@ def test_taken_json(self):
response = self.client.get(url)
struct = json.loads(response.content)
- from dates.views import get_taken_info
+ from apps.dates.views import get_taken_info
eq_(struct, get_taken_info(user))
def test_notify(self):
@@ -415,7 +415,7 @@ def test_save_settings(self):
struct = json.loads(response.content)
ok_(struct['ok'])
- from users.models import UserProfile
+ from apps.users.models import UserProfile
profile = UserProfile.objects.get(user__username='peter')
eq_(profile.country, 'GB')
eq_(profile.city, 'London')
@@ -446,7 +446,7 @@ def test_save_settings_security_hack(self):
struct = json.loads(response.content)
ok_(struct['ok'])
- from users.models import UserProfile
+ from apps.users.models import UserProfile
profile = UserProfile.objects.get(user__username='peter')
eq_(profile.country, 'GB')
eq_(profile.city, 'London')
File renamed without changes.
@@ -11,10 +11,10 @@
from django.conf import settings
from django.shortcuts import redirect, get_object_or_404, render
from django.contrib.auth import login as auth_login, logout as auth_logout
-from dates.models import Entry, Hours
-from dates.decorators import json_view
-from dates.utils import get_weekday_dates
-from users.forms import ProfileForm
+from apps.dates.models import Entry, Hours
+from apps.dates.decorators import json_view
+from apps.dates.utils import get_weekday_dates
+from apps.users.forms import ProfileForm
MOBILE_DATE_FORMAT = '%Y-%m-%d'
@@ -40,8 +40,8 @@ def appcache(request):
def right_now(request):
if not request.user.is_authenticated(): # XXX improve this
return {'error': 'Not logged in'}
- from dates.views import get_right_nows, get_upcomings
- from dates.helpers import format_date
+ from apps.dates.views import get_right_nows, get_upcomings
+ from apps.dates.helpers import format_date
right_nows, right_now_users = get_right_nows()
upcomings, upcoming_users = get_upcomings(14)
@@ -94,7 +94,7 @@ def right_now(request):
def taken(request):
if not request.user.is_authenticated(): # XXX improve this
return {'error': 'Not logged in'}
- from dates.views import get_taken_info
+ from apps.dates.views import get_taken_info
return get_taken_info(request.user)
@@ -105,8 +105,8 @@ def taken(request):
def notify(request):
if not request.user.is_authenticated(): # XXX improve this
return {'error': 'Not logged in'}
- from dates.forms import AddForm
- from dates.views import clean_unfinished_entries
+ from apps.dates.forms import AddForm
+ from apps.dates.views import clean_unfinished_entries
form = AddForm(request.user, data=request.POST)
if form.is_valid():
start = form.cleaned_data['start']
@@ -143,8 +143,8 @@ def save_hours(request):
if entry.user != request.user:
return http.HttpResponseForbidden("Not your entry")
- from dates.forms import HoursForm
- from dates.views import save_entry_hours, send_email_notification
+ from apps.dates.forms import HoursForm
+ from apps.dates.views import save_entry_hours, send_email_notification
form = HoursForm(entry, data=request.POST)
if form.is_valid():
total_hours, is_edit = save_entry_hours(entry, form)
@@ -199,7 +199,7 @@ def settings_json(request):
'username': request.user.username,
'email': request.user.email,
}
- from dates.helpers import full_name_form
+ from apps.dates.helpers import full_name_form
data['full_name'] = full_name_form(None, request.user)
profile = request.user.get_profile()
if profile.start_date:
@@ -244,7 +244,7 @@ def login(request):
if request.method == 'GET':
return {'logged_in': request.user.is_authenticated()}
- from users.forms import AuthenticationForm
+ from apps.users.forms import AuthenticationForm
form = AuthenticationForm(data=request.POST)
if form.is_valid():
auth_login(request, form.get_user())
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -5,7 +5,7 @@
from django import forms
import django.contrib.auth.forms
from .models import UserProfile
-from dates.forms import BaseModelForm
+from apps.dates.forms import BaseModelForm
from lib.country_aliases import ALIASES as COUNTRY_ALIASES
File renamed without changes.
@@ -14,10 +14,10 @@
from mock import Mock
import ldap
-from users.auth.backends import MozillaLDAPBackend
-from users.utils.ldap_mock import MockLDAP
-from users.models import UserProfile
-from users.utils import ldap_lookup
+from apps.users.auth.backends import MozillaLDAPBackend
+from apps.users.utils.ldap_mock import MockLDAP
+from apps.users.models import UserProfile
+from apps.users.utils import ldap_lookup
RaiseInvalidCredentials = object()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1 @@
+"""Application base, containing global templates."""
File renamed without changes.
No changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html LANG="{{ LANG }}" dir="{{ DIR }}">
+ <head>
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
+ <title>{% block page_title %}playdoh examples{% endblock %}</title>
+
+ {% block site_css %}
+ {{ css('example_css') }}
+ {% endblock %}
+ </head>
+ <body data-mobile-cookie="{{ settings.MOBILE_COOKIE }}">
+ {% block content %}{% endblock %}
+
+ <div id="footer">
+ {# These links will add/remove cookies. See JavaScript. #}
+ <a class="desktop-link" href="">{{ _('View Desktop Site') }}</a>
+ &nbsp;|&nbsp;
+ <a class="mobile-link" href="">{{ _('View Mobile Site') }}</a>
+ </div>
+
+ {% block site_js %}
+ {{ js('example_js') }}
+ {% endblock %}
+ </body>
+</html>
+
Oops, something went wrong.

0 comments on commit 2b3d556

Please sign in to comment.