Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adiciona models iniciais #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,45 @@
*.log
# python and django
*.py[cod]
*.pot
*.pyc
local_settings.py
*.Python
*.db
media/
build/
dist/
*settings_local.py
include/

# C extensions
*.so

# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64

# Installer logs
pip-log.txt

# Unit test / coverage reports
.coverage
.tox
nosetests.xml

# Translations
*.mo

# ide
*.sublime*

# other
*.DS_Store
2 changes: 1 addition & 1 deletion volunter/manage.py → volunteer/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.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions volunteer/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 volunteer/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')
16 changes: 16 additions & 0 deletions volunteer/volunteer/app/core/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""

from django.test import TestCase


class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
1 change: 1 addition & 0 deletions volunteer/volunteer/app/core/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your views here.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Django==1.5.1
argparse==1.2.1
distribute==0.6.24
wsgiref==0.1.2
wsgiref==0.1.2
34 changes: 17 additions & 17 deletions volunter/volunter/settings.py → volunteer/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 volunteer/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 → volunteer/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
17 changes: 0 additions & 17 deletions volunter/volunter/urls.py

This file was deleted.