Giter Site home page Giter Site logo

onepercentclub / onepercentclub-site Goto Github PK

View Code? Open in Web Editor NEW
13.0 19.0 13.0 112.34 MB

The repository for 1%Club website.

Home Page: https://onepercentclub.com

License: BSD 3-Clause "New" or "Revised" License

JavaScript 5.17% CSS 10.76% HTML 27.50% Python 46.29% Handlebars 7.55% ApacheConf 0.43% Shell 2.27% Ruby 0.03%

onepercentclub-site's Introduction

1%Club's website

This is 1%Club's website. This site is proudly built using BlueBottle, the crowdfundning and crowdsourcing framework developed by the 1%Club.

https://travis-ci.org/onepercentclub/onepercentclub-site.png?branch=master

Getting started

  1. Make sure you have a recent Python distro (2.7+ recommended)

  2. Make sure (a recent) pip is installed

  3. Make sure (a recent) virtualenv is installed

  4. Clone the repo

  5. In the repo dir, execute the following (tested with Bash, might work with others as well):

    ./prepare.sh
    
  6. Configure your database in onepercentclub/settings/secrets.py.

  7. Activate the newly created environment in env:

    source env/bin/activate
    
  8. Update database structure:

    ./manage.py syncdb --migrate
    
  9. You're ready to roll now.

Requirements and environment

Requirements for the virtual environment can be found in requirements.txt and the environment itself is in env in the project's root dir. It is automatically ignored through .gitignore.

Translations

Translations are managed using Transifex. Feel free to contribute and collaborate at the Transifex project page.

Settings

Bluebottle has different settings for different environments as described in the "Settings and Requirements Files" chapter of 2 Scoops of Django. The settings can be found in onepercentclub/settings:

  • base.py: Project defaults used in any settings environment.
  • secrets.py: Used for storing passwords, API keys etc. This is not stored in Git.
  • local.py: Local settings used in personal development environment. This is not stored in Git.
  • jenkins.py: Settings for our Jenkins setup.
  • travis.py: Settings for Travis CI.
  • dev.py: Settings for the development server.
  • testing.py: Settings for the testing server.
  • production.py: Settings for the testing server.

Specific settings can be used by setting the environment variable DJANGO_SETTINGS_MODULE to onepercentclub.settings.<settings name>:

export DJANGO_SETTINGS_MODULE=onepercentclub.settings.local

Alternately you can specify the settings manually when you use ./manage.py:

./manage.py runserver --settings=onepercentclub.settings.local

Deployment

For deployment, we're using Fabric. In order to deploy, the user should have his/her SSH public key authorized for the user onepercentadmin on the development, testing, staging and production environments. After this has been done, make sure you use the environment and run:

fab --list

This will display all the available Fabric commands, which are defined in fabfile.py.

To deploy the latest version on dev to testing:

fab deploy_testing

To deploy an older version to staging, say we want to revert to staging-66:

fab deploy_staging:revspec=staging-66

Same goes for production

Fixtures

Some models have default data which can be loaded after you run syncdb with this command:

./manage.py loaddata <name of json file without extension>

For example, this command loads the data for the Bluebottle geo app:

./manage.py loaddata region_subregion_country_data

You can find a list of data files with this command run from the onepercentclub-site directory:

find apps -name \*.json

Running Tests

*Frontend Javascript*

From the root of the application (node/npm required):

npm install grunt (or grunt test:chrome)

This will install some npm & bower packages for dev & testing, and run the tests headless with PhantomJS using Karma. Karma is watching the test/ directory for changes.

License

1%Club's website is distributed under a 3-clause BSD license. For more information, please refer to the license.

onepercentclub-site's People

Contributors

aethemba avatar alextreme avatar benkonrath avatar dokterbob avatar franstwisk avatar gannetson avatar jfterpstra avatar jhonm avatar joeribekker avatar jose-lpa avatar mg84 avatar netogallo avatar prashantpalikhe avatar rollick avatar sergei-maertens avatar stevano avatar vdboor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onepercentclub-site's Issues

Restructure Django settings

Because settings are getting a mess and do not fit well within an automated deployment environment, I propose to restructure them in order to:

  • Make them more uniform
  • Allow for better structure, and thus provide more oversight
  • Make local overrides optional rather than required

Part of this restructuring should take into account cleanup up prepare.sh to fit our current scenario better and disabling the SQLite database by default. An added advantage of this is a simplification of the automated deployment and testing setup.

In the current setup, the import hierarchy for settings is as follows:

__init__.py
 `- local.py
     `- default.py
         `- global_settings (Django's defaults)
     `- secret.py

user_testing.py (testing.onepercentclub.com)
`- testing.py (Jenkins)
   `- local.py
       `- default.py
         `- global_settings (Django's defaults)
       `- secret.py

As with automated deployment, we should refrain from local overrides - but still might want to have them available in our development environments, I propose to change to the following scheme:

__init__.py -> development.py (symlink)

development.py
  |- default.py
  |   `- global_settings (Django's defaults)
  |- secret.py
  |- <environment-specific overrides>
  `- local.py (optional)

jenkins.py
  |- default.py
  |   `- global_settings (Django's defaults)
  |- secret.py
  |- <environment-specific overrides>
  `- local.py (optional)

legacymigration.py
  |- default.py
  |   `- global_settings (Django's defaults)
  |- secret.py
  |- <environment-specific overrides>
  `- local.py (optional)

testing.py
  |- default.py
  |   `- global_settings (Django's defaults)
  |- secret.py
  |- <environment-specific overrides>
  `- local.py (optional)

staging.py
  |- default.py
  |   `- global_settings (Django's defaults)
  |- secret.py
  |- <environment-specific overrides>
  `- local.py (optional)

production.py
  |- default.py
  |   `- global_settings (Django's defaults)
  |- secret.py
  |- <environment-specific overrides>
  `- local.py (optional)

This setup is largely based on the following scheme, with the addition of local settings overrides: https://code.djangoproject.com/wiki/SplitSettings#SimplePackageOrganizationforEnvironments

In this setup, an environment-specific configuration file would look like this:

""" 
BIG FAT WARNING: DO NOT EDIT HERE

Make changes to your settings below
"""
# Load the default settings from default.py
from .default import *

# Attempt to load 'secret' settings, containing (ie.) passwords from secret.py
from .secret import *

"""
MAKE CHANGES BELOW
Put your environment-specific settings overrides below
"""



DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'onepercentsite',
        'USER': 'onepercentsite'
    },
}




"""
BIG FAT WARNING: DO NOT EDIT BELOW
Make changes above.
"""

# Allow for (optional) local settings overrides
try:
    from .local import *
except ImportError:
    print('Could not import local settings overrides.')

Language not saved in session or cookie

The selected language seems to be purely influenced by the URL. There is no session or cookie that stores the language.

There is ofcourse the user profile language, but no such thing for anonymous users.

Restructure fixture loading

Currently, we have fixtures for two kinds of objects:

  • Country's, regions, etc.
  • Project categories

Soon, we will be adding fixtures for the sites app (#67) and probably more are to follow in the near future.

As we discussed before, we want to really watch out with loading fixtures automatically by putting them in the fixtures/initial_data.json. However, when having four deployment environments, having to maintain code for all fixture loading becomes a burden.

This is why I'd like to propose using the FIXTURE_DIRS setting to explicitly designate folders with 'deployment fixtures', ie. called deploy_fixtures. By calling them initial_data.json we can have them automatically loaded and we can choose to not have them loaded in deployment-environment specific settings, ie. skip it in staging, production and testing environments.

Moreover, this would lighten the burdon of having to maintain explicitly fixture loading for different environments in deployment scenario's.

the oembed tests displays irrelevant debug information

% ./manage.py test
nosetests --verbosity 1 --detailed-errors
To reuse old database "test_bluebottle" for speed, set env var REUSE_DB=1.
To reuse old database "test_onepercentclub" for speed, set env var REUSE_DB=1.
Creating test database for alias 'default'...
Creating test database for alias 'legacy'...
.......[03/Aug/2012 14:30:20] DEBUG Found OEmbed data on http://www.youtube.com/watch?v=54XHDUOHuzU for None
[03/Aug/2012 14:30:20] DEBUG Setting field provider_url on None to http://www.youtube.com/
[03/Aug/2012 14:30:20] DEBUG Setting field title on None to Future Crew - Second Reality demo - HD
[03/Aug/2012 14:30:20] DEBUG Setting field html on Future Crew - Second Reality demo - HD to <iframe width="459" height="344" src="http://www.youtube.com/embed/54XHDUOHuzU?fs=1&feature=oembed" frameborder="0" allowfullscreen></iframe>
[03/Aug/2012 14:30:20] DEBUG Setting field author_name on Future Crew - Second Reality demo - HD to pascalbrax
[03/Aug/2012 14:30:20] DEBUG Setting field height on Future Crew - Second Reality demo - HD to 344
[03/Aug/2012 14:30:20] DEBUG Setting field width on Future Crew - Second Reality demo - HD to 459
[03/Aug/2012 14:30:20] DEBUG Setting field thumbnail_url on Future Crew - Second Reality demo - HD to http://i2.ytimg.com/vi/54XHDUOHuzU/hqdefault.jpg
[03/Aug/2012 14:30:20] DEBUG Setting field thumbnail_width on Future Crew - Second Reality demo - HD to 480
[03/Aug/2012 14:30:20] DEBUG Setting field provider_name on Future Crew - Second Reality demo - HD to YouTube
[03/Aug/2012 14:30:20] DEBUG Setting field thumbnail_height on Future Crew - Second Reality demo - HD to 360
[03/Aug/2012 14:30:20] DEBUG Setting field author_url on Future Crew - Second Reality demo - HD to http://www.youtube.com/user/pascalbrax
[03/Aug/2012 14:30:20] ERROR Could not find metadata for object.
Traceback (most recent call last):
File "/home/ben/Development/onepercentclub/bluebottle/apps/media/models.py", line 86, in clean
oembed_data = providers.request(self.url)
File "/home/ben/Development/onepercentclub/bluebottle/env/local/lib/python2.7/site-packages/micawber/providers.py", line 82, in inner
return fn(self, url, *_params)
File "/home/ben/Development/onepercentclub/bluebottle/env/local/lib/python2.7/site-packages/micawber/providers.py", line 108, in request
return provider.request(url, *_params)
File "/home/ben/Development/onepercentclub/bluebottle/env/local/lib/python2.7/site-packages/micawber/providers.py", line 61, in request
raise ProviderException('Error fetching "%s"' % endpoint_url)
ProviderException: Error fetching "http://www.youtube.com/oembed?format=json&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dbnanana"

..............

Ran 21 tests in 2.162s

OK
Destroying test database for alias 'default'...
Destroying test database for alias 'legacy'...

Still required to log in

Whenever I'm not logged in and I do a request I still get the basic HTTP login dialog. Or again? Anyways: read operations (to the API or otherwise) should be free for now, AFAIK.

SSL errors

The intermediate certificate is not included in the SSL chain supplied to browsers, as a result of which all properly configured browsers are unable to visit the site. In any case Chrome and Firefox (latest versions) refuse to open the site without a warning.

More info on properly configuring SSL:
https://www.ssllabs.com/ssltest/analyze.html?d=onepercentclub.com

Also turns out you're not mitigating the BEAST-attack and have a few weak ciphers enabled. See link above for simple clues on how to fix that.

Cleanup filenames and extensions for contributed media

For user media, we should take care of automatically renaming the files and normalizing/detecting/setting the extensions. Whatever method we should should work from withing the migration as well, where a mimetype is not commonly available.

Suggested method: use python-magic (libmagic wrapper) for detecting the mimetype and then use python's very own mimetypes library to determine the proper extension.

Performance tips

The current load time from the US is about 8.12 seconds with a total download size of over a megabyte and 78 requests. From Amsterdam the load time is still about 7.4 seconds and on my tablet is well over 30 seconds.

Tests have been performed using Pingdom, where there's also a whole lot of tips on how to solve some of the performance issues on the site.

http://tools.pingdom.com/fpt/#!/SfYg1/onepercentclub.com (second tab is the most interesting)

Some important ones:

  • Serve static assets from a different subdomain for parallel loading and no cookies.
  • Set very large expire headers on static assets for which the filename is a unique hash.
  • Compile HBS templates into combined JS.
  • Set ETag and Last Modified headers on API query results.
  • Load GA stuff and other similar things that are not directly needed for the functioning of the page just before closing the </body> tag. Of course, you might have already done this.
  • What else are you pulling in that leads to a 1 MB download size?

Deprecation error on legacyauth

/usr/local/lib/python2.6/dist-packages/django/contrib/auth/__init__.py:26: DeprecationWarning: Authentication backends without asupports_inactive_userattribute are deprecated. Please define it in <class 'legacyauth.backends.EmailBackend'>.

Password reset mail in different language

I noticed the password reset mail is sent in Dutch, even if I perform all actions on the English version of the website. Seems the selected language is not correctly stored/retrieved.

Furthermore, I believe the user language (in his/her profile) is not taken into account.
In the email user function, there should be something like:

with django.utils.translation.override(user.primary_language):
    # render template strings

Remove 'verify_exists'

There are a few cases where I've used the deprecated verify_exists on URLFields, which should be removed.

Project entry in admin requires all phases to be present

When creating a project in the admin, it seems that all the available phases have to be entered. Moreover, multiple phases can be attached to a project.

To circumvent this, two things have to happen:

  • A uniqueness constraind unique=True should be added to the AbstractPhase
  • A max_num should be set on the inline, ref

Evaluate DTAP-server requirements (consider downgrade)

Currently, the staging is running with 512MB RAM and the testing server has 1,5G. We should probably consider upgrading the staging server to either 768 MB or 1G - and consider downgrading the testing server to the same.

Probably best to evaluate performance and OOM problems.

Project slugs should be unique

They are used in URL's - hence some projects do not have a URL right now. This also has to be accounted for in migrations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.