Skip to content

Commit

Permalink
chore: move most website-related modules to 'website' (hedyorg#468)
Browse files Browse the repository at this point in the history
* chore: move most website-related modules to 'website'

It's getting quite crowded with `.py` files in the root of the
repository. Move most of the modules that have something to do
with the website to a submodule called `website`.

* Fix imports

* Rename test method.

Co-authored-by: Federico Pereiro <[email protected]>
  • Loading branch information
rix0rrr and fpereiro authored Jun 7, 2021
1 parent 7fba89b commit a015544
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 19 deletions.
11 changes: 3 additions & 8 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import collections
import hedy
import json
import jsonbin
import logging
import os
from os import path
Expand All @@ -19,7 +18,7 @@
from flask_commonmark import Commonmark
from werkzeug.urls import url_encode
from config import config
from auth import auth_templates, current_user, requires_login, is_admin, is_teacher
from website.auth import auth_templates, current_user, requires_login, is_admin, is_teacher
from utils import db_get, db_get_many, db_create, db_update, timems, type_check, object_check, db_del, load_yaml, load_yaml_rt, dump_yaml_rt, version
import utils

Expand All @@ -31,11 +30,7 @@
# Hedy-specific modules
import courses
import hedyweb
import translating
import querylog
import aws_helpers
import ab_proxying
import cdn
from website import querylog, aws_helpers, jsonbin, translating, ab_proxying, cdn

# Set the current directory to the root Hedy folder
os.chdir(os.path.join (os.getcwd (), __file__.replace (os.path.basename (__file__), '')))
Expand Down Expand Up @@ -830,7 +825,7 @@ def update_yaml():

# *** AUTH ***

import auth
from website import auth
auth.routes (app, requested_lang)

# *** START SERVER ***
Expand Down
2 changes: 1 addition & 1 deletion flask_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import flask
import querylog
from website import querylog

@querylog.timed
def render_template(filename, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
def worker_exit(server, worker):
# When the worker is being exited (perhaps because of a timeout),
# give the query_log handler a chance to flush to disk.
import querylog
from website import querylog
querylog.emergency_shutdown()
2 changes: 1 addition & 1 deletion hedyweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from flask_helpers import render_template

import courses
from auth import current_user
from website.auth import current_user
from utils import type_check
import re
import utils
Expand Down
2 changes: 1 addition & 1 deletion tests/test_abproxying.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ab_proxying
from website import ab_proxying
import unittest

class TestAbTesting(unittest.TestCase):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_querylog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import querylog
from website import querylog
import unittest

class TestQueryLog(unittest.TestCase):
Expand Down Expand Up @@ -29,10 +29,10 @@ def test_emergency_recovery(self):
recovered_queue.try_load_emergency_saves()
recovered_queue.set_transmitter(self._fake_transmitter)

self.assertEquals(self.records, [])
self.assertEqual(self.records, [])

recovered_queue.transmit_now()

self.assertEqual(self.records[0]['banaan'], 'geel')
self.assertEqual(self.records[0]['bloem'], 'rood')
self.assertEqual(self.records[0]['terminated'], True)
self.assertEqual(self.records[0]['terminated'], True)
2 changes: 1 addition & 1 deletion tests/test_translating.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
import utils
import translating
from website import translating

class TestTranslating(unittest.TestCase):
def test_change_nested_records(self):
Expand Down
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import re
from ruamel import yaml
import querylog
from website import querylog


class Timer:
Expand Down
Empty file added website/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion ab_proxying.py → website/ab_proxying.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import flask.sessions
import itsdangerous

from auth import current_user
from .auth import current_user
import utils

class ABProxying:
Expand Down
2 changes: 1 addition & 1 deletion auth.py → website/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from botocore.exceptions import ClientError as email_error
import json
import requests
import querylog
from website import querylog

cookie_name = config ['session'] ['cookie_name']
session_length = config ['session'] ['session_length'] * 60
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a015544

Please sign in to comment.