-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from agiliq/16-admin
Allow easy inclusion with Admin
- Loading branch information
Showing
12 changed files
with
1,568 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from django.contrib import admin | ||
|
||
from django.contrib.auth.models import User | ||
from django.contrib.auth.admin import UserAdmin | ||
|
||
from parsley.mixins import ParsleyAdminMixin | ||
|
||
|
||
class MyUserAdmin(ParsleyAdminMixin, UserAdmin): | ||
pass | ||
|
||
|
||
admin.site.unregister(User) | ||
admin.site.register(User, MyUserAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
from django.conf.urls import patterns, url | ||
from django.contrib import admin | ||
from django.conf.urls import patterns, url, include | ||
|
||
from core.views import HomeView | ||
|
||
admin.autodiscover() | ||
|
||
urlpatterns = patterns( | ||
'core.views', | ||
|
||
urlpatterns = patterns('core.views', | ||
url(r'^admin/', include(admin.site.urls)), | ||
url(r'^$', HomeView.as_view(), name='home'), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from parsley.decorators import parsleyfy | ||
|
||
|
||
class ParsleyAdminMixin(object): | ||
|
||
def get_form(self, *args, **kwargs): | ||
form = super(ParsleyAdminMixin, self).get_form(*args, **kwargs) | ||
return parsleyfy(form) | ||
|
||
class Media: | ||
js = ( | ||
"parsley/js/parsley-standalone.min.js", | ||
"parsley/js/parsley.django-admin.js", | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Parsley.js - django admin helper | ||
*/ | ||
|
||
!function ($) { | ||
'use strict'; | ||
|
||
$( window ).on( 'load', function () { | ||
$( 'form' ).each( function () { | ||
$( this ).parsley({ | ||
animate: false, | ||
errors: { | ||
errorsWrapper: '<ul class="errorlist"></ul>', | ||
container: function (element, isRadioOrCheckbox) { | ||
return $("<div />").prependTo(element.closest(".form-row")); | ||
} | ||
}, | ||
listeners: { | ||
onFieldError: function (element) { | ||
var container = element.closest(".form-row"); | ||
if (container.not(".errors")) { | ||
container.addClass("errors"); | ||
} | ||
} | ||
} | ||
}); | ||
} ); | ||
} ); | ||
}(window.jQuery || window.Zepto); |
Oops, something went wrong.