Permalink
Browse files

Early prep for HTMLification #118

  • Loading branch information...
1 parent c9db094 commit 624cbfe2e125b1812f8809ab3ee977cef6711332 @pydanny committed Aug 18, 2012
Showing with 16 additions and 11 deletions.
  1. +1 −1 core/tests/test_utils.py
  2. +1 −1 core/utils.py
  3. +4 −1 package/forms.py
  4. +8 −8 package/views.py
  5. +1 −0 requirements.txt
  6. +1 −0 settings/base.py
View
2 core/tests/test_utils.py
@@ -37,4 +37,4 @@ def test_get_pypi_url_fail(self):
'php is not here'
)
for l in lst:
- self.assertEquals(utils.get_pypi_url(l[0]), None)
+ self.assertEquals(utils.get_pypi_url(l), None)
View
2 core/utils.py
@@ -16,7 +16,7 @@ def oc_slugify(value):
def get_pypi_url(title):
title = title.strip()
- for value in [title, title.lower(), oc_slugify(title), title.title()]:
+ for value in [title, title.lower(), oc_slugify(title), title.title(), ]:
value = 'http://pypi.python.org/pypi/' + value
r = requests.get(value)
if r.status_code == 200:
View
5 package/forms.py
@@ -1,4 +1,4 @@
-from django.forms import ModelForm
+from floppyforms import ModelForm, TextInput
from package.models import Category, Package, PackageExample
@@ -20,6 +20,9 @@ def __init__(self, *args, **kwargs):
super(PackageForm, self).__init__(*args, **kwargs)
self.fields['category'].help_text = package_help_text()
self.fields['repo_url'].required = True
+ self.fields['repo_url'].widget = TextInput(attrs={
+ 'placeholder': 'ex: https://github.com/django/django'
+ })
def clean_slug(self):
return self.cleaned_data['slug'].lower()
View
16 package/views.py
@@ -57,32 +57,32 @@ def add_package(request, template_name="package/package_form.html"):
if not request.user.get_profile().can_add_package:
return HttpResponseForbidden("permission denied")
-
new_package = Package()
form = PackageForm(request.POST or None, instance=new_package)
-
+
package_extenders = build_package_extenders(request)
-
+
if form.is_valid():
new_package = form.save()
new_package.created_by = request.user
new_package.last_modified_by = request.user
new_package.save()
new_package.fetch_metadata()
-
+
# stick in package_extender form processing
for package_extender in package_extenders:
if package_extender['form'].is_valid():
- package_extender['form'].save()
- return HttpResponseRedirect(reverse("package", kwargs={"slug":new_package.slug}))
-
+ package_extender['form'].save()
+ return HttpResponseRedirect(reverse("package", kwargs={"slug": new_package.slug}))
+
return render(request, template_name, {
"form": form,
"repo_data": repo_data_for_js(),
"action": "add",
- "package_extenders":package_extenders
+ "package_extenders": package_extenders
})
+
@login_required
def edit_package(request, slug, template_name="package/package_form.html"):
View
1 requirements.txt
@@ -9,6 +9,7 @@ dj-database-url==0.1.2
django-classy-tags==0.3.3.1
django-coverage==1.2.1
django-extensions==0.4.1
+django-floppyforms==1.0
django-heroku-memcacheify==0.1
django-heroku-postgresify==0.2
django-pagination==1.0.7
View
1 settings/base.py
@@ -149,6 +149,7 @@
#'djcelery',
'social_auth',
+ 'floppyforms',
]

0 comments on commit 624cbfe

Please sign in to comment.