diff --git a/webroot/AutoSa/AutoSa/urls.py b/webroot/AutoSa/AutoSa/urls.py index 26e545d65..d16a55e60 100644 --- a/webroot/AutoSa/AutoSa/urls.py +++ b/webroot/AutoSa/AutoSa/urls.py @@ -10,6 +10,7 @@ urlpatterns = patterns('', # url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), + (r'^install/', views.install), (r'^$', views.index), (r'^login/$', views.login), (r'^logout/$', views.logout), diff --git a/webroot/AutoSa/AutoSa/views.py b/webroot/AutoSa/AutoSa/views.py index 4bbbd6135..9ec484d31 100644 --- a/webroot/AutoSa/AutoSa/views.py +++ b/webroot/AutoSa/AutoSa/views.py @@ -207,6 +207,22 @@ def is_super_user(request): return False +def install(request): + user = User.objects.filter(username='admin') + if user: + return HttpResponseRedirect('/login/') + else: + u = User( + username='admin', + password=md5_crypt('admin'), + key_pass=md5_crypt('admin'), + name='admin', + is_admin=False, + is_superuser=True, + ldap_password=md5_crypt('admin')) + u.save() + + def login(request): """登录界面""" if request.session.get('username'):