Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmachine committed May 6, 2015
0 parents commit b7bad32
Show file tree
Hide file tree
Showing 26 changed files with 477 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[run]
branch = True
omit = */migrations/__init__.py
source = eventkit

[report]
exclude_lines =
def __repr__
pragma: no cover
raise AssertionError
raise NotImplementedError
show_missing = True
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{css,html,js,json}]
indent_style = tab
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Only include files that are actually generated or required by the app.

# For anything that is local to your environment, e.g. dotfiles created by your
# IDE, use your own `~/.gitignore_global` file.

*.egg-info/
*.py[co]
/.coverage
/.tox/
/db.sqlite3
/htmlcov/
/venv/
61 changes: 61 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Readme

Docs can be found in the [docs](docs/index.md) folder.

## App Template

This is a bare-bones skeleton app template, for use with the
`django-admin.py startapp` command.

You will need `django 1.4+`, `git`, `python 2.7+`, `pip`, and `virtualenv` to
create a new app with this template.

Create environment variables for the app and module name (e.g. `django-foo-bar`
and `foo_bar`), so we can use them in subsequent commands:

$ export APP=<app_name>
$ export MODULE=<module_name>

Create an app from the template:

$ mkdir $APP
$ django-admin.py startapp -e md,yml -n .coveragerc \
--template=https://github.com/ixc/ixc-app-template/archive/master.zip \
$MODULE $APP

Make the `manage.py` file executable, for convenience:

$ cd $APP
$ chmod 755 manage.py

Create a remote repository on [GitHub], then initialise a local repository and
push an initial commit:

$ git init
$ git add -A
$ git commit -m 'Initial commit.'
$ git remote add origin [email protected]:ixc/$APP.git
$ git push

Create a virtualenv and install the dependencies:

$ virtualenv venv
$ source venv/bin/activate
(venv)$ pip install -r requirements.txt

Run the tests:

(venv)$ tox

Now, write your app! You might want to start with:

* Remove the `App Template` section (these instructions) from `README.md`
(this file).
* Add a `LICENSE` file (e.g. [MIT]).
* Update the `docs/index.md` file (e.g. the overview, installation and usage
sections).
* Read the [contributing] docs.

[contributing]: docs/contributing.md
[GitHub]: https://github.com
[MIT]: http://choosealicense.com/licenses/mit/
9 changes: 9 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changelog

## 0.1 (in development)

Features:

* Created app from [ixc-app-template]

[ixc-app-template]: https://github.com/ixc/ixc-app-template/
79 changes: 79 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Contributing

Please follow these guidelines when making contributions to this app.

## Getting Started

Get the code and setup a virtualenv:

$ git clone [email protected]:ixc/<app_name>.git
$ cd <app_name>
$ virtualenv venv
$ source venv/bin/activate
(venv)$ pip install -r requirements.txt

Run the tests:

# All environments, just the given environments, or just the virtualenv.
(venv)$ tox
(venv)$ tox -e django17-py27,django18-py27
(venv)$ ./manage.py test

Run the test project interactively:

(venv)$ ./manage.py migrate
(venv)$ ./manage.py runserver

## Git

We are using the [Gitflow branching model]. Basically:

* The `master` branch always contains production ready code, and each commit
represents a release to production.
* The `develop` branch serves as an integration branch for new features, and
is merged into `master` when we are ready to tag a new release.
* New features are developed in `feature/*` branches. Create a pull request
when you are ready to merge a feature branch back into `develop`.

The [SourceTree] app (OS X and Windows) has built-in support for Gitflow, and
there is also a collection of [git-extensions] for command line users.

## Code Style

It's important that we all adopt a consistent code style to minimise code churn
and make collaboration easier.

* Follow [PEP8] for Python code, unless there is a good reason not to.
* Install the [EditorConfig] plugin for your preferred code editor.

## Documentation

Docs are probably more important than tests!

* Write [Markdown] docs for all notable changes and additions.
* Include examples so new contributors can get started quickly.
* Include rationale when there are competing solutions, so people know why
they should use our solution.
* Keep the [changelog] up to date. Use plain language to describe changes,
as it may be read by people who are not as familiar with the project or a
particular feature as you.

## Tests

We don't need 100% test coverage, but we should at least have:

* Unit tests for all regression bugs.
* Unit or integration tests for complex, fragile, or important functionality.

## Releases

* When the changelog for a release gets sufficiently long (half a page to a
page) or major features or fixes are implemented, tag a release.

[changelog]: changelog.md
[EditorConfig]: http://editorconfig.org/
[git-extensions]: https://github.com/nvie/gitflow/
[Gitflow branching model]: http://atlassian.com/git/workflows#!workflow-gitflow
[Markdown]: http://daringfireball.net/projects/markdown/
[PEP8]: http://legacy.python.org/dev/peps/pep-0008/
[SourceTree]: http://sourcetreeapp.com/
42 changes: 42 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Overview

TODO

## Table of Contents

* [Changelog]
* [Contributing]

## Installation

Install the app into your virtualenv:

(venv)$ pip install -e git+ssh://[email protected]/ixc/<app_name>.git#egg=<app_name>

Update your settings module:

INSTALLED_APPS += ('eventkit', )

## Usage

TODO

## HTML Docs

Docs are written in [Markdown]. You can use [MkDocs] to build a static HTML
version that you can host anywhere:

(venv)$ mkdocs build

Or you can use the built-in dev server to preview your documentation as you're
writing it:

(venv)$ mkdocs serve

It will even auto-reload whenever you save any changes, so all you need to do
to see your latest edits is refresh your browser.

[Changelog]: changelog.md
[Contributing]: contributing.md
[Markdown]: http://daringfireball.net/projects/markdown/
[MkDocs]: http://mkdocs.org
3 changes: 3 additions & 0 deletions eventkit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__version__ = '0.1'

default_app_config = 'eventkit.apps.AppConfig'
10 changes: 10 additions & 0 deletions eventkit/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
Admin configuration for ``eventkit`` app.
"""

# Define `list_display`, `list_filter` and `search_fields` for each model.
# These go a long way to making the admin more usable.

from django.contrib import admin

from eventkit import models
12 changes: 12 additions & 0 deletions eventkit/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
App configuration for ``eventkit`` app.
"""

# Register signal handlers, but avoid interacting with the database.
# See: https://docs.djangoproject.com/en/1.8/ref/applications/#django.apps.AppConfig.ready

from django.apps import AppConfig


class AppConfig(AppConfig):
name = 'eventkit'
7 changes: 7 additions & 0 deletions eventkit/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Forms for ``eventkit`` app.
"""

from django import forms

from eventkit import models
7 changes: 7 additions & 0 deletions eventkit/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
try:
from django.db import migrations
except ImportError:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured(
'These migrations are for use with Django 1.7 and above. For Django '
'1.6 and below, upgrade to South 1.0.')
31 changes: 31 additions & 0 deletions eventkit/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Models for ``eventkit`` app.
"""

# Compose concrete models from abstract models and mixins, to facilitate reuse.

from django.db import models
from django.utils import timezone


class AbstractBaseModel(models.Model):
"""
Abstract base model.
"""

created = models.DateTimeField(
default=timezone.now, db_index=True, editable=False)
modified = models.DateTimeField(
default=timezone.now, db_index=True, editable=False)

class Meta:
abstract = True
get_latest_by = 'pk'
ordering = ('-id', )

def save(self, *args, **kwargs):
"""
Update ``self.modified``.
"""
self.modified = timezone.now()
super(AbstractBaseModel, self).save(*args, **kwargs)
1 change: 1 addition & 0 deletions eventkit/templates/eventkit/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World
Empty file added eventkit/tests/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions eventkit/tests/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Test models for ``eventkit`` app.
"""

from eventkit import models


class BaseModel(models.AbstractBaseModel):
"""
Concrete base model.
"""
pass
33 changes: 33 additions & 0 deletions eventkit/tests/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Test settings for ``eventkit`` app.
"""

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite3',
}
}

DEBUG = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django_nose',
'eventkit',
'eventkit.tests'
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'eventkit.urls'
SECRET_KEY = 'secret-key'
STATIC_URL = '/static/'
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
34 changes: 34 additions & 0 deletions eventkit/tests/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Tests for ``eventkit`` app.
"""

# WebTest API docs: http://webtest.readthedocs.org/en/latest/api.html

from django.core.urlresolvers import reverse
from django_dynamic_fixture import G
from django_webtest import WebTest

from eventkit import forms, models, views
from eventkit.tests import models as test_models


class Forms(WebTest):
def test(self):
pass


class Models(WebTest):
def test_BaseModel(self):
"""
Test that ``modified`` field is updated on save.
"""
obj = G(test_models.BaseModel)
modified = obj.modified
obj.save()
self.assertNotEqual(obj.modified, modified)


class Views(WebTest):
def test_index(self):
response = self.app.get(reverse('eventkit_index'))
response.mustcontain('Hello World')
Loading

0 comments on commit b7bad32

Please sign in to comment.