Skip to content

Commit

Permalink
Blackened code with Flake8 issues fixed and a few small typo bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Apr 13, 2020
1 parent 4d0514c commit 35c4678
Show file tree
Hide file tree
Showing 173 changed files with 7,433 additions and 3,079 deletions.
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version = 1

test_patterns = [

]

exclude_patterns = [
Expand Down
60 changes: 60 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/lucasmbrown/mirrors-autoflake
rev: v1.3
hooks:
- id: autoflake
args:
[
'--in-place',
'--remove-all-unused-imports',
'--ignore-init-module-imports',
'--remove-unused-variable',
]
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
additional_dependencies:
- toml
- repo: https://github.com/ambv/black
rev: master
hooks:
- id: black
language_version: python3.7
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-xml
- id: fix-encoding-pragma
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
additional_dependencies:
- toml
- flake8-assertive
- flake8-blind-except
- flake8-builtins
- flake8-coding
- flake8-comprehensions
- flake8-isort
- flake8-logging-format
- flake8-mutable
- flake8-print
- pep8-naming
- repo: https://github.com/prettier/prettier
rev: master
hooks:
- id: prettier
args: ['--single-quote', '--trailing-comma', 'es5']
4 changes: 4 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
singleQuote: true,
trailingComma: 'es5',
};
2 changes: 1 addition & 1 deletion .pyup.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
schedule: "every month"
schedule: 'every month'
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ script: ./runtests.sh
after_success:
- coveralls
addons:
postgresql: "9.4"
postgresql: '9.4'
services:
- redis-server
notifications:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ ADD . /code/hasjob
WORKDIR /code/hasjob/

EXPOSE 5000
EXPOSE 5432
EXPOSE 5432
61 changes: 30 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
Hasjob
======
# Hasjob

Code for Hasjob, HasGeek’s job board at https://hasjob.co/

Copyright © 2010-2018 by HasGeek

Hasjob’s code is open source under the AGPL v3 license (see LICENSE.txt). We welcome your examination of our code to:

* Establish trust and transparency on how it works, and
* Allow contributions to Hasjob.
- Establish trust and transparency on how it works, and
- Allow contributions to Hasjob.

Our workflow assumes this code is for use on a single production website. Using this to operate your own job board is not recommended. The name ‘Hasjob’ and the distinctive appearance of the job board are not part of the open source code.

Expand All @@ -22,40 +21,40 @@ Hasjob can be used with Docker (recommended for quick start) or the harder way w

Hasjob requires a `FLASK_ENV` environment variable set to one of the following values, depending on whether the deployment is in development or production:

* `DEVELOPMENT` or `development` or `dev` (default)
* `PRODUCTION` or `production` or `prod`
- `DEVELOPMENT` or `development` or `dev` (default)
- `PRODUCTION` or `production` or `prod`

In a production environment, you must set `FLASK_ENV` globally for it to be available across processes. On Ubuntu/Debian systems, add it to `/etc/environment` and reboot.

### With Docker

#### Install and run with Docker

* Install [Docker](https://docs.docker.com/installation/) and [Compose](https://docs.docker.com/compose/install/)
- Install [Docker](https://docs.docker.com/installation/) and [Compose](https://docs.docker.com/compose/install/)

* Next, rename the `instance/development.docker.py` to `instance/development.py`
- Next, rename the `instance/development.docker.py` to `instance/development.py`

* Build the images
- Build the images

```
$ docker-compose build
```
```
$ docker-compose build
```

* Initialize the database
- Initialize the database

```
$ docker-compose run web sh
web$ python manage.py db create
web$ exit
```
```
$ docker-compose run web sh
web$ python manage.py db create
web$ exit
```

* Start the server
- Start the server

```
$ docker-compose up
```
```
$ docker-compose up
```

* You can edit the server name and Lastuser settings in `docker-compose.yml`
- You can edit the server name and Lastuser settings in `docker-compose.yml`

### Without Docker

Expand Down Expand Up @@ -86,15 +85,15 @@ Redis does not require special configuration, but must listen on localhost and p

Hasjob makes use of subdomains to serve different sub-boards for jobs. To set it up:

* Edit `/etc/hosts` and add these entries (substituting `your-machine` with whatever you call your computer):
- Edit `/etc/hosts` and add these entries (substituting `your-machine` with whatever you call your computer):

```
127.0.0.1 hasjob.your-machine.local
127.0.0.1 static.hasjob.your-machine.local
127.0.0.1 subboard.hasjob.your-machine.local
```
```
127.0.0.1 hasjob.your-machine.local
127.0.0.1 static.hasjob.your-machine.local
127.0.0.1 subboard.hasjob.your-machine.local
```

* Edit `instance/development.py` and change `SERVER_NAME` to `'hasjob.your-machine.local:5000'`
- Edit `instance/development.py` and change `SERVER_NAME` to `'hasjob.your-machine.local:5000'`

#### Install dependencies

Expand Down Expand Up @@ -123,7 +122,7 @@ Finish configuration with:
$ python manage.py db create

You will need to install all dependencies listed in `package.json`

$ cd hasjob/assets
$ npm install

Expand Down
14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ web:
build: .
command: python /code/hasjob/runserver.py &
volumes:
- .:/code/hasjob
- .:/code/hasjob
environment:
SERVER_NAME: hasjob.docker.dev
LASTUSER_SERVER: https://auth.hasgeek.com
LASTUSER_CLIENT_ID: client-key-here
LASTUSER_CLIENT_SECRET: client-secret-here
links:
- pg
- redis
- pg
- redis
ports:
- "5000:5000"
- "5432:5432"
- "6379:6379"
- '5000:5000'
- '5432:5432'
- '6379:6379'
pg:
image: postgres
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
redis:
image: redis
image: redis
13 changes: 8 additions & 5 deletions get-twitter.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Get Twitter access key and secret.
"""

import tweepy
from hasjob import app, init_for
import tweepy

init_for('dev')
auth = tweepy.OAuthHandler(app.config['TWITTER_CONSUMER_KEY'], app.config['TWITTER_CONSUMER_SECRET'])
auth = tweepy.OAuthHandler(
app.config['TWITTER_CONSUMER_KEY'], app.config['TWITTER_CONSUMER_SECRET']
)
auth_url = auth.get_authorization_url()
print('Please authorize: ' + auth_url)
print("Please authorize: " + auth_url) # NOQA: T001
verifier = input('PIN: ').strip()
auth.get_access_token(verifier)
print("TWITTER_ACCESS_KEY = '%s'" % auth.access_token.key)
print("TWITTER_ACCESS_SECRET = '%s'" % auth.access_token.secret)
print("TWITTER_ACCESS_KEY = '%s'" % auth.access_token.key) # NOQA: T001
print("TWITTER_ACCESS_SECRET = '%s'" % auth.access_token.secret) # NOQA: T001
74 changes: 54 additions & 20 deletions hasjob/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
# -*- coding: utf-8 -*-

import os.path
import geoip2.database

from flask import Flask
from flask_migrate import Migrate
from flask_assets import Bundle
from flask_rq2 import RQ
from flask_mail import Mail
from flask_migrate import Migrate
from flask_redis import FlaskRedis
from flask_rq2 import RQ

import geoip2.database

from baseframe import Version, assets, baseframe
from flask_lastuser import Lastuser
from flask_lastuser.sqlalchemy import UserManager
from baseframe import baseframe, assets, Version
import coaster.app
from ._version import __version__

from ._version import __version__
from .uploads import configure as uploads_configure

# First, make an app and config it

Expand All @@ -29,8 +33,8 @@

# Third, after config, import the models and views

from . import models, views # NOQA
from .models import db # NOQA
from . import models, views # NOQA # isort:skip
from .models import db # NOQA # isort:skip

# Configure the app
coaster.app.init_app(app)
Expand All @@ -40,30 +44,60 @@
app.geoip = None
if 'GEOIP_PATH' in app.config:
if not os.path.exists(app.config['GEOIP_PATH']):
app.logger.warn("GeoIP database missing at " + app.config['GEOIP_PATH'])
app.logger.warning("GeoIP database missing at %s", app.config['GEOIP_PATH'])
else:
app.geoip = geoip2.database.Reader(app.config['GEOIP_PATH'])

rq.init_app(app)

baseframe.init_app(app, requires=['baseframe-bs3', 'jquery.autosize', 'jquery.liblink',
'jquery.wnumb', 'jquery.nouislider', 'baseframe-firasans', 'fontawesome>=4.3.0',
'bootstrap-multiselect', 'nprogress', 'ractive', 'jquery.appear', 'hammer'])
baseframe.init_app(
app,
requires=[
'baseframe-bs3',
'jquery.autosize',
'jquery.liblink',
'jquery.wnumb',
'jquery.nouislider',
'baseframe-firasans',
'fontawesome>=4.3.0',
'bootstrap-multiselect',
'nprogress',
'ractive',
'jquery.appear',
'hammer',
],
)

# FIXME: Hack for external build system generating relative /static URLs.
# Fix this by generating absolute URLs to the static subdomain during build.
app.add_url_rule('/static/<path:filename>', endpoint='static',
view_func=app.send_static_file, subdomain=None)
app.add_url_rule('/static/<path:filename>', endpoint='static',
view_func=app.send_static_file, subdomain='<subdomain>')
app.add_url_rule(
'/static/<path:filename>',
endpoint='static',
view_func=app.send_static_file,
subdomain=None,
)
app.add_url_rule(
'/static/<path:filename>',
endpoint='static',
view_func=app.send_static_file,
subdomain='<subdomain>',
)

# TinyMCE has to be loaded by itself, unminified, or it won't be able to find its assets
app.assets.register('js_tinymce', assets.require('!jquery.js', 'tinymce.js>=4.0.0', 'jquery.tinymce.js>=4.0.0'))
app.assets.register('css_editor', Bundle('css/editor.css',
filters=['cssrewrite', 'cssmin'], output='css/editor.packed.css'))
app.assets.register(
'js_tinymce',
assets.require('!jquery.js', 'tinymce.js>=4.0.0', 'jquery.tinymce.js>=4.0.0'),
)
app.assets.register(
'css_editor',
Bundle(
'css/editor.css',
filters=['cssrewrite', 'cssmin'],
output='css/editor.packed.css',
),
)

from hasjob.uploads import configure as uploads_configure
uploads_configure()
uploads_configure(app)
mail.init_app(app)
redis_store.init_app(app)
lastuser.init_app(app)
Expand Down
6 changes: 5 additions & 1 deletion hasjob/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
__all__ = ['__version__', '__version_info__']

__version__ = '0.3.0'
__version_info__ = tuple([int(num) if num.isdigit() else num for num in __version__.replace('-', '.', 1).split('.')])
__version_info__ = tuple(
int(num) if num.isdigit() else num
for num in __version__.replace('-', '.', 1).split('.')
)
2 changes: 1 addition & 1 deletion hasjob/assets/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["es2015"]
}
}
Loading

0 comments on commit 35c4678

Please sign in to comment.