Skip to content

Commit

Permalink
add models and rename project. pug-se#1
Browse files Browse the repository at this point in the history
  • Loading branch information
matheussl committed Jul 7, 2013
1 parent 6b05773 commit fc6c51b
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 39 deletions.
2 changes: 1 addition & 1 deletion volunter/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "volunter.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "volunteer.settings")

from django.core.management import execute_from_command_line

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions volunter/volunteer/app/core/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin

from models import Profile
from models import Organization
from models import Opportunity
from models import Collaboration

admin.site.register(Profile)
admin.site.register(Organization)
admin.site.register(Opportunity)
admin.site.register(Collaboration)
48 changes: 48 additions & 0 deletions volunter/volunteer/app/core/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from django.db import models


class DefaultFields(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
active = models.BooleanField(default=True)

class Meta:
abstract = True


class Profile(DefaultFields):
user = models.OneToOneField('auth.User', related_name='profile')
birth_date = models.DateField()


class Organization(DefaultFields):
# required
owner = models.ForeignKey('auth.User', related_name='organizations')
name = models.CharField(max_length=100)
description = models.TextField()
# optional
site = models.URLField(null=True, blank=True)
cnpj = models.CharField(max_length=14, null=True, blank=True)


class Opportunity(DefaultFields):
# relation
organization = models.ForeignKey('Organization', related_name='opportunities')
volunteers = models.ManyToManyField('auth.User', related_name='opportunities', through='Collaboration')
# required
title = models.CharField(max_length=200)
description = models.TextField()
location = models.CharField(max_length=200)
# optional
min_volunteer = models.IntegerField(null=True, blank=True)
max_volunteer = models.IntegerField(null=True, blank=True)
site = models.URLField()


class Collaboration(DefaultFields):
opportunity = models.ForeignKey('Opportunity', related_name='collaborations')
user = models.ForeignKey('auth.User', related_name='collaborations')
confirmed = models.BooleanField()

class Meta:
unique_together = ('opportunity', 'user')
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 17 additions & 17 deletions volunter/volunter/settings.py → volunter/volunteer/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Django settings for volunter project.
from unipath import Path


PROJECT_DIR = Path(__file__).parent

DEBUG = True
TEMPLATE_DEBUG = DEBUG
Expand All @@ -11,8 +14,8 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': PROJECT_DIR.child('volunteer.db'),
# The following settings are not used with sqlite3:
'USER': '',
'PASSWORD': '',
Expand Down Expand Up @@ -50,36 +53,34 @@

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''
MEDIA_ROOT = PROJECT_DIR.child('media')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''
STATIC_ROOT = PROJECT_DIR.child('static')

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
PROJECT_DIR.child('volunteer', 'static'),
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
Expand All @@ -89,7 +90,7 @@
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
# 'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
Expand All @@ -102,10 +103,10 @@
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'volunter.urls'
ROOT_URLCONF = 'volunteer.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'volunter.wsgi.application'
WSGI_APPLICATION = 'volunteer.wsgi.application'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
Expand All @@ -120,10 +121,9 @@
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'django.contrib.admin',
# our
'volunteer.app.core',
)

# A sample logging configuration. The only tangible logging
Expand Down
7 changes: 7 additions & 0 deletions volunter/volunteer/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
)
2 changes: 1 addition & 1 deletion volunter/volunter/wsgi.py → volunter/volunteer/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# if running multiple sites in the same mod_wsgi process. To fix this, use
# mod_wsgi daemon mode with each site in its own daemon process, or use
# os.environ["DJANGO_SETTINGS_MODULE"] = "volunter.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "volunter.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "volunteer.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
Expand Down
3 changes: 0 additions & 3 deletions volunter/volunter/app/core/models.py

This file was deleted.

17 changes: 0 additions & 17 deletions volunter/volunter/urls.py

This file was deleted.

0 comments on commit fc6c51b

Please sign in to comment.