mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
no imports * and unused import
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
# coding: utf-8
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
class LoginForm(forms.Form):
|
||||
username = forms.CharField(
|
||||
label=_("Username"),
|
||||
widget=forms.TextInput(attrs={"class" : "span3"})
|
||||
)
|
||||
widget=forms.TextInput(attrs={"class": "span3"})
|
||||
)
|
||||
password = forms.CharField(
|
||||
label=_("Password"),
|
||||
widget=forms.PasswordInput(attrs={"class" : "span3"})
|
||||
)
|
||||
widget=forms.PasswordInput(attrs={"class": "span3"})
|
||||
)
|
||||
rememberme = forms.BooleanField(
|
||||
initial=False,
|
||||
required=False
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
# coding: utf-8
|
||||
|
||||
import crypt, hashlib
|
||||
import string
|
||||
from random import Random
|
||||
from Crypto.Cipher import AES
|
||||
import base64
|
||||
from modoboa.lib import parameters
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# coding: utf-8
|
||||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
@@ -20,4 +21,3 @@ Another way to test that 1 + 1 is equal to 2.
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
|
||||
|
||||
@@ -4,31 +4,31 @@ from django.contrib.auth import authenticate, login, logout
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from modoboa.lib import events
|
||||
from modoboa.lib import events, parameters
|
||||
from modoboa.lib.webutils import _render_to_string
|
||||
from modoboa.lib.sysutils import log_warning
|
||||
from modoboa.admin import views as admviews
|
||||
from forms import LoginForm
|
||||
from modoboa.auth.lib import *
|
||||
from modoboa.auth.lib import encrypt
|
||||
|
||||
def dologin(request):
|
||||
error = None
|
||||
if request.method == "POST":
|
||||
form = LoginForm(request.POST)
|
||||
if form.is_valid():
|
||||
user = authenticate(username=form.cleaned_data["username"],
|
||||
user = authenticate(username=form.cleaned_data["username"],
|
||||
password=form.cleaned_data["password"])
|
||||
if user and user.is_active:
|
||||
if not form.cleaned_data["rememberme"]:
|
||||
request.session.set_expiry(0)
|
||||
login(request, user)
|
||||
login(request, user)
|
||||
if request.user.id != 1:
|
||||
request.session["password"] = encrypt(request.POST["password"])
|
||||
|
||||
request.session["django_language"] = \
|
||||
parameters.get_user(request.user, "LANG", app="general")
|
||||
|
||||
events.raiseEvent("UserLogin", request,
|
||||
events.raiseEvent("UserLogin", request,
|
||||
form.cleaned_data["username"],
|
||||
form.cleaned_data["password"])
|
||||
|
||||
@@ -38,7 +38,7 @@ def dologin(request):
|
||||
return HttpResponseRedirect(next)
|
||||
error = _("Your username and password didn't match. Please try again.")
|
||||
log_warning("Failed connection attempt from %(addr)s as user %(user)s" \
|
||||
% {"addr" : request.META["REMOTE_ADDR"],
|
||||
% {"addr" : request.META["REMOTE_ADDR"],
|
||||
"user" : form.cleaned_data["username"]})
|
||||
|
||||
next = request.POST.get("next", None)
|
||||
@@ -49,7 +49,7 @@ def dologin(request):
|
||||
httpcode = 200
|
||||
|
||||
return HttpResponse(_render_to_string(request, "registration/login.html", {
|
||||
"form" : form, "error" : error, "next" : next,
|
||||
"form" : form, "error" : error, "next" : next,
|
||||
"annoucements" : events.raiseQueryEvent("GetAnnouncement", "loginpage")
|
||||
}), status=httpcode)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# coding: utf-8
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
@@ -53,7 +54,7 @@ class DeployCommand(Command):
|
||||
output = None
|
||||
if p.returncode:
|
||||
if output:
|
||||
print >>sys.stderr, "\n".join(filter(lambda l: l != None, output))
|
||||
print >>sys.stderr, "\n".join(filter(lambda l: l is not None, output))
|
||||
print >>sys.stderr, "%s failed, check your configuration" % cmd
|
||||
|
||||
def ask_db_info(self, name='default'):
|
||||
@@ -65,8 +66,7 @@ class DeployCommand(Command):
|
||||
:param name: the connection name
|
||||
"""
|
||||
print "Configuring database connection: %s" % name
|
||||
info = {'conn_name' : name}
|
||||
info['dbtype'] = raw_input('Database type (mysql or postgres): ')
|
||||
info = {'conn_name': name, 'dbtype': raw_input('Database type (mysql or postgres): ')}
|
||||
if info['dbtype'] not in ['mysql', 'postgres']:
|
||||
info['dbtype'] = 'mysql'
|
||||
if info['dbtype'] == 'postgres':
|
||||
@@ -78,7 +78,7 @@ class DeployCommand(Command):
|
||||
info['username'] = raw_input('Username: ')
|
||||
info['password'] = getpass.getpass('Password: ')
|
||||
return info
|
||||
|
||||
|
||||
def handle(self, parsed_args):
|
||||
management.call_command('startproject', parsed_args.name, verbosity=False)
|
||||
if os.path.exists("%(name)s/%(name)s" % {'name' : parsed_args.name}):
|
||||
@@ -90,7 +90,7 @@ class DeployCommand(Command):
|
||||
path = parsed_args.name
|
||||
sys.path.append(".")
|
||||
django14 = False
|
||||
|
||||
|
||||
t = Template(dbconn_tpl)
|
||||
default_conn = t.render(Context(self.ask_db_info()))
|
||||
amavis_conn = t.render(Context(self.ask_db_info('amavis'))) if parsed_args.with_amavis \
|
||||
@@ -107,10 +107,10 @@ class DeployCommand(Command):
|
||||
fp.close()
|
||||
shutil.copyfile("%s/urls.py" % self._templates_dir, "%s/urls.py" % path)
|
||||
os.mkdir("%s/media" % path)
|
||||
|
||||
|
||||
if parsed_args.syncdb:
|
||||
self._exec_django_command("syncdb", parsed_args.name, '--migrate', '--noinput')
|
||||
self._exec_django_command("loaddata", parsed_args.name, 'initial_users.json')
|
||||
|
||||
|
||||
if parsed_args.collectstatic:
|
||||
self._exec_django_command("collectstatic", parsed_args.name, '--noinput')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# coding: utf-8
|
||||
import sys
|
||||
from modoboa.core.management import Command
|
||||
|
||||
@@ -8,7 +9,7 @@ class HelpCommand(Command):
|
||||
super(HelpCommand, self).__init__(*args, **kwargs)
|
||||
self._parser.add_argument('name', type=str,
|
||||
help='A command name')
|
||||
|
||||
|
||||
def handle(self, parsed_args):
|
||||
if not self._commands.has_key(parsed_args.name):
|
||||
print >>sys.stderr, "Unknown command: %s" % parsed_args.name
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# coding: utf-8
|
||||
import getpass
|
||||
import inspect
|
||||
import os
|
||||
@@ -84,14 +85,14 @@ class PostfixMapsCommand(Command):
|
||||
help='Used database type')
|
||||
self._parser.add_argument('--dbhost', type=str, default='127.0.0.1',
|
||||
help='Database host address')
|
||||
self._parser.add_argument('--categories', type=str, nargs='*', default=['std'],
|
||||
self._parser.add_argument('--categories', type=str, nargs='*', default=['std'],
|
||||
help='Map file categories to generate (choices: std, autoreply)')
|
||||
|
||||
|
||||
def handle(self, parsed_args):
|
||||
dbname = raw_input('Database name: ')
|
||||
dbuser = raw_input('Username: ')
|
||||
dbpass = getpass.getpass('Password: ')
|
||||
|
||||
|
||||
try:
|
||||
os.mkdir(parsed_args.destdir)
|
||||
except OSError:
|
||||
@@ -102,6 +103,6 @@ class PostfixMapsCommand(Command):
|
||||
continue
|
||||
if not v.category in parsed_args.categories:
|
||||
continue
|
||||
v().render(parsed_args.destdir, parsed_args.dbtype,
|
||||
dbname=dbname, dbuser=dbuser, dbpassword=dbpass,
|
||||
v().render(parsed_args.destdir, parsed_args.dbtype,
|
||||
dbname=dbname, dbuser=dbuser, dbpassword=dbpass,
|
||||
dbhost=parsed_args.dbhost)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# coding: utf-8
|
||||
# This is an auto-generated Django model module.
|
||||
# You'll have to do the following manually to clean this up:
|
||||
# * Rearrange models' order
|
||||
|
||||
Reference in New Issue
Block a user