Panayiotis Lipiridis avatar Panayiotis Lipiridis committed 830db5a Merge

Merge with gae-init

Comments (0)

Files changed (5)

 import auth
 import util
 import model
+import config
 
 from main import app
 
     config_db.twitter_consumer_key = form.twitter_consumer_key.data
     config_db.twitter_consumer_secret = form.twitter_consumer_secret.data
     config_db.put()
-    update_config_variables(config_db)
+    reload(config)
+    app.config.update(CONFIG_DB=config_db)
     flask.flash('Your config settings have been saved', category='success')
     return flask.redirect(flask.url_for('welcome'))
   if not form.errors:
       form=form,
       config_db=config_db,
     )
-
-
-def update_config_variables(config_db):
-  app.config.update(
-      CONFIG_DB=config_db,
-      SECRETE_KEY=config_db.flask_secret_key,
-    )
 
 import util
 import model
+import config
+
 from main import app
 
 
 def retrieve_user_from_google(google_user):
   user_db = model.User.retrieve_one_by('federated_id', google_user.user_id())
   if user_db:
+    if not user_db.admin and users.is_current_user_admin():
+      user_db.admin = True
+      user_db.put()
     return user_db
   user_db = model.User(
       federated_id=google_user.user_id(),
     request_token_url='https://api.twitter.com/oauth/request_token',
     access_token_url='https://api.twitter.com/oauth/access_token',
     authorize_url='https://api.twitter.com/oauth/authenticate',
-    consumer_key=model.Config.get_master_db().twitter_consumer_key,
-    consumer_secret=model.Config.get_master_db().twitter_consumer_secret,
+    consumer_key=config.CONFIG_DB.twitter_consumer_key,
+    consumer_secret=config.CONFIG_DB.twitter_consumer_secret,
   )
 
 
     request_token_url=None,
     access_token_url='/oauth/access_token',
     authorize_url='https://www.facebook.com/dialog/oauth',
-    consumer_key=model.Config.get_master_db().facebook_app_id,
-    consumer_secret=model.Config.get_master_db().facebook_app_secret,
+    consumer_key=config.CONFIG_DB.facebook_app_id,
+    consumer_secret=config.CONFIG_DB.facebook_app_secret,
     request_token_params={'scope': 'email'},
   )
 
   flask_user_db = FlaskUser(user_db)
   if flaskext.login.login_user(flask_user_db):
     flask.flash('Hello %s, welcome to %s!!!' % (
-        user_db.name, model.Config.get_master_db().brand_name,
+        user_db.name, config.CONFIG_DB.brand_name,
       ), category='success')
     return flask.redirect(util.get_next_url())
   else:
   form = FeedbackForm()
   if form.validate_on_submit():
     mail.send_mail(
-        sender=model.Config.get_master_db().feedback_email,
-        to=model.Config.get_master_db().feedback_email,
+        sender=config.CONFIG_DB.feedback_email,
+        to=config.CONFIG_DB.feedback_email,
         subject='[%s] %s' % (
-            model.Config.get_master_db().brand_name,
+            config.CONFIG_DB.brand_name,
             form.subject.data,
           ),
-        reply_to=form.email.data or model.Config.get_master_db().feedback_email,
+        reply_to=form.email.data or config.CONFIG_DB.feedback_email,
         body='%s\n\n%s' % (form.feedback.data, form.email.data)
       )
     flask.flash('Thank you for your feedback!', category='success')
Add a comment to this file

main/templates/admin/config_update.html

File contents unchanged.

Add a comment to this file

main/templates/profile.html

File contents unchanged.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.