1
1
# -*- coding: utf-8 -*-
2
2
3
- # Coil CMS v1.1 .0
3
+ # Coil CMS v1.2 .0
4
4
# Copyright © 2014-2015 Chris Warrick, Roberto Alsina, Henry Hirsch et al.
5
5
6
6
# Permission is hereby granted, free of charge, to any
46
46
from passlib .hash import bcrypt_sha256
47
47
from coil .utils import USER_FIELDS , PERMISSIONS , PERMISSIONS_E , SiteProxy
48
48
from coil .forms import (LoginForm , NewPostForm , NewPageForm , DeleteForm ,
49
- UserDeleteForm , UserEditForm , AccountForm ,
50
- PermissionsForm , UserImportForm , PwdHashForm )
49
+ UserDeleteForm , UserEditForm , AccountForm ,
50
+ PermissionsForm , UserImportForm , PwdHashForm )
51
51
52
52
_site = None
53
53
site = None
@@ -160,8 +160,8 @@ def configure_site():
160
160
_site .config ['TRANSLATIONS' ])
161
161
162
162
# Theme must inherit from bootstrap3, because we have hardcoded HTML.
163
- bs3 = (('bootstrap3' in _site .THEMES )
164
- or ('bootstrap3-jinja' in _site .THEMES ))
163
+ bs3 = (('bootstrap3' in _site .THEMES ) or
164
+ ('bootstrap3-jinja' in _site .THEMES ))
165
165
if not bs3 :
166
166
app .logger .notice ("THEME does not inherit from 'bootstrap3' or "
167
167
"'bootstrap3-jinja', using 'bootstrap3' instead." )
@@ -252,7 +252,7 @@ def generate_menu():
252
252
if needs_rebuild not in ('0' , '-1' ):
253
253
return ('</li><li><a href="{0}"><i class="fa fa-fw '
254
254
'fa-warning"></i> <strong>Rebuild</strong></a></li>' .format (
255
- url_for ('rebuild' )))
255
+ url_for ('rebuild' )))
256
256
else :
257
257
return ('</li><li><a href="{0}"><i class="fa fa-fw '
258
258
'fa-cog"></i> Rebuild</a></li>' .format (url_for ('rebuild' )))
@@ -602,8 +602,8 @@ def index():
602
602
posts = []
603
603
pages = []
604
604
for p in site .timeline :
605
- if (p .meta ('author.uid' )
606
- and p .meta ('author.uid' ) != str (current_user .uid )):
605
+ if (p .meta ('author.uid' ) and
606
+ p .meta ('author.uid' ) != str (current_user .uid )):
607
607
continue
608
608
if p .is_post :
609
609
posts .append (p )
@@ -637,8 +637,8 @@ def edit(path):
637
637
638
638
current_auid = int (post .meta ('author.uid' ) or current_user .uid )
639
639
640
- if (not current_user .can_edit_all_posts
641
- and current_auid != current_user .uid ):
640
+ if (not current_user .can_edit_all_posts and
641
+ current_auid != current_user .uid ):
642
642
return error ("Cannot edit posts of other users." , 401 )
643
643
644
644
if request .method == 'POST' :
@@ -652,8 +652,8 @@ def edit(path):
652
652
author_change_success = True
653
653
except :
654
654
author_change_success = False
655
- if (not current_user .can_transfer_post_authorship
656
- or not author_change_success ):
655
+ if (not current_user .can_transfer_post_authorship or
656
+ not author_change_success ):
657
657
meta ['author' ] = post .meta ('author' ) or current_user .realname
658
658
meta ['author.uid' ] = str (current_auid )
659
659
@@ -690,7 +690,8 @@ def edit(path):
690
690
if db is not None :
691
691
uids = db .hgetall ('users' ).values ()
692
692
for u in uids :
693
- realname , active = db .hmget ('user:{0}' .format (u ), 'realname' , 'active' )
693
+ realname , active = db .hmget ('user:{0}' .format (u ),
694
+ 'realname' , 'active' )
694
695
if active == '1' :
695
696
users .append ((u , realname ))
696
697
else :
@@ -721,8 +722,8 @@ def delete():
721
722
722
723
current_auid = int (post .meta ('author.uid' ) or current_user .uid )
723
724
724
- if (not current_user .can_edit_all_posts
725
- and current_auid != current_user .uid ):
725
+ if (not current_user .can_edit_all_posts and
726
+ current_auid != current_user .uid ):
726
727
return error ("Cannot edit posts of other users." , 401 )
727
728
728
729
os .unlink (path )
@@ -760,8 +761,8 @@ def api_rebuild():
760
761
d = json .dumps ({'build' : build_job .meta , 'orphans' : orphans_job .meta })
761
762
762
763
if ('status' in build_job .meta and
763
- build_job .meta ['status' ] is not None
764
- and 'status' in orphans_job .meta and
764
+ build_job .meta ['status' ] is not None and
765
+ 'status' in orphans_job .meta and
765
766
orphans_job .meta ['status' ] is not None ):
766
767
rq .cancel_job ('build' , db )
767
768
rq .cancel_job ('orphans' , db )
@@ -787,22 +788,21 @@ def rebuild(mode=''):
787
788
db .set ('site:needs_rebuild' , '-1' )
788
789
if not q .fetch_job ('build' ) and not q .fetch_job ('orphans' ):
789
790
b = q .enqueue_call (func = coil .tasks .build ,
790
- args = (app .config ['REDIS_URL' ],
791
- app .config ['NIKOLA_ROOT' ], mode ), job_id = 'build' )
791
+ args = (app .config ['REDIS_URL' ],
792
+ app .config ['NIKOLA_ROOT' ], mode ),
793
+ job_id = 'build' )
792
794
q .enqueue_call (func = coil .tasks .orphans ,
793
- args = (app .config ['REDIS_URL' ],
794
- app .config ['NIKOLA_ROOT' ]), job_id = 'orphans' ,
795
- depends_on = b )
795
+ args = (app .config ['REDIS_URL' ],
796
+ app .config ['NIKOLA_ROOT' ]), job_id = 'orphans' ,
797
+ depends_on = b )
796
798
return render ('coil_rebuild.tmpl' , {'title' : 'Rebuild' })
797
799
else :
798
800
status , outputb = coil .tasks .build_single (mode )
799
801
_ , outputo = coil .tasks .orphans_single ()
800
802
site .coil_needs_rebuild = '0'
801
- return render ('coil_rebuild_single.tmpl' , {'title' : 'Rebuild' ,
802
- 'status' : '1' if status else '0' ,
803
- 'outputb' : outputb ,
804
- 'outputo' : outputo })
805
-
803
+ return render ('coil_rebuild_single.tmpl' ,
804
+ {'title' : 'Rebuild' , 'status' : '1' if status else '0' ,
805
+ 'outputb' : outputb , 'outputo' : outputo })
806
806
807
807
808
808
@app .route ('/new/<obj>/' , methods = ['POST' ])
@@ -965,10 +965,10 @@ def acp_pwdhash():
965
965
else :
966
966
pwdhash = None
967
967
status = False
968
- return render ('coil_pwdhash.tmpl' , context = { 'title' : 'My account' ,
969
- 'pwdhash' : pwdhash ,
970
- 'status' : status ,
971
- 'form' : form })
968
+ return render ('coil_pwdhash.tmpl' ,
969
+ context = { 'title' : 'My account' , 'pwdhash' : pwdhash ,
970
+ 'status' : status , 'form' : form })
971
+
972
972
973
973
@app .route ('/users/' )
974
974
@login_required
0 commit comments