1. Nikolaj Šujskij
  2. gruq

Commits

Alexander Vershilov  committed a754ec7

Syntax fixes

  • Participants
  • Parent commits f81d288
  • Branches default

Comments (0)

Files changed (1)

File main.py

View file
  • Ignore whitespace
     sender = wtforms.TextField('Отправитель')
     text = wtforms.TextAreaField('Цитата', [wtforms.validators.Required()])
     author = wtforms.TextField('Автор')
-    source = wtforms.RadioField('Место', [wtforms.validators.Required()], choices=SRC_CHOICES)
+    source = wtforms.RadioField('Место', [wtforms.validators.Required()], 
+            choices=SRC_CHOICES)
     prooflink = wtforms.TextField('Ссылка', [wtforms.validators.Required()])
 
 class LoginForm(wtforms.Form):
-    username = wtforms.TextField('Username',[wtforms.validators.Required()])
-    password = wtforms.PasswordField('Password',[wtforms.validators.Required()])
+    username = wtforms.TextField('Username', [wtforms.validators.Required()])
+    password = wtforms.PasswordField('Password', [wtforms.validators.Required()])
 
 @quoteapp.route('/')
 def index():
             database.db.session.commit()
             return render_template('sucess.html', quote=q)
         else:
-            return render_template('append.html', form=form);
+            return render_template('append.html', form=form)
     else:
-        return abort(404);
+        return abort(404)
 
 @quoteapp.route('/list/')
 def list_all():
 @quoteapp.route('/abyss/', methods=['GET','POST'])
 def list_abyss():
     if request.method == 'POST':
-        data = request.form.getlist('abyss');
+        data = request.form.getlist('abyss')
         if data and check_moderator():
-            q = None;
+            command = None
             if request.form.get('delete') is not None:
-                q = abbys_delete;
+                command = abbys_delete
             if request.form.get('approve') is not None:
-                q = abbys_approve;
-            q(data);
+                command = abbys_approve
+            command(data)
     return list(approved=False, can_moder=True)
 
 def abbys_delete(data):
     ##TODO: **kwargs to filter
-    database.db.session.query(database.Quote).\
-            filter(database.Quote.id.in_(data)).\
-            filter(database.Quote.is_approved == 0).\
-            delete(False);
-    database.db.session.commit();
+    database.db.session.query(database.Quote).filter(
+            database.Quote.id.in_(data)).filter(
+                    database.Quote.is_approved == 0).delete(False)
+    database.db.session.commit()
 
 def abbys_approve(data):
     ##TODO: **kwargs to filter
-    database.db.session.query(database.Quote).\
-            filter(database.Quote.id.in_(data)).\
-            filter(database.Quote.is_approved == 0).\
-            update({'is_approved':1}, False);
-    database.db.session.commit();
+    database.db.session.query(database.Quote).filter(
+            database.Quote.id.in_(data)).filter(
+                    database.Quote.is_approved == 0).update({'is_approved':1}, False)
+    database.db.session.commit()
 
 def check_moderator():
     name = session.get('user')
     if name is not None:
-        u = database.db.session.query(database.User).\
-           filter(database.User.name==name).first();
-        if ( u is None):
-           session.pop('user',None)
+        user = database.db.session.query(database.User).filter(
+                database.User.name == name).first()
+        if user is None:
+           session.pop('user', None)
         return True
     return False
 
     if request.method == 'POST':
         # totally stupid and insecure, yes
         if form.validate():
-            u = database.db.session.query(database.User).\
-                  filter(database.User.name==form.username.data).\
-                  filter(database.User.password==form.password.data).first();
-            if  u is not None:
-                session['user'] = u.name;
+            user = database.db.session.query(
+                    database.User).filter(
+                            database.User.name == form.username.data).filter(
+                                    database.User.password == form.password.data).first()
+            if  user is not None:
+                session['user'] = user.name
                 #TODO: make named redirect
                 return redirect('/abyss')