diff --git a/volunter/manage.py b/volunter/manage.py index e42cffe..46ec271 100644 --- a/volunter/manage.py +++ b/volunter/manage.py @@ -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 diff --git a/volunter/volunter/__init__.py b/volunter/volunteer/__init__.py similarity index 100% rename from volunter/volunter/__init__.py rename to volunter/volunteer/__init__.py diff --git a/volunter/volunter/app/__init__.py b/volunter/volunteer/app/__init__.py similarity index 100% rename from volunter/volunter/app/__init__.py rename to volunter/volunteer/app/__init__.py diff --git a/volunter/volunter/app/core/__init__.py b/volunter/volunteer/app/core/__init__.py similarity index 100% rename from volunter/volunter/app/core/__init__.py rename to volunter/volunteer/app/core/__init__.py diff --git a/volunter/volunteer/app/core/admin.py b/volunter/volunteer/app/core/admin.py new file mode 100644 index 0000000..d90bb45 --- /dev/null +++ b/volunter/volunteer/app/core/admin.py @@ -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) diff --git a/volunter/volunteer/app/core/models.py b/volunter/volunteer/app/core/models.py new file mode 100644 index 0000000..148cec3 --- /dev/null +++ b/volunter/volunteer/app/core/models.py @@ -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') diff --git a/volunter/volunter/app/core/tests.py b/volunter/volunteer/app/core/tests.py similarity index 100% rename from volunter/volunter/app/core/tests.py rename to volunter/volunteer/app/core/tests.py diff --git a/volunter/volunter/app/core/views.py b/volunter/volunteer/app/core/views.py similarity index 100% rename from volunter/volunter/app/core/views.py rename to volunter/volunteer/app/core/views.py diff --git a/volunter/volunter/requirements/base.txt b/volunter/volunteer/requirements/base.txt similarity index 100% rename from volunter/volunter/requirements/base.txt rename to volunter/volunteer/requirements/base.txt diff --git a/volunter/volunter/settings.py b/volunter/volunteer/settings.py similarity index 84% rename from volunter/volunter/settings.py rename to volunter/volunteer/settings.py index b196f8e..32eb14d 100644 --- a/volunter/volunter/settings.py +++ b/volunter/volunteer/settings.py @@ -1,4 +1,7 @@ -# Django settings for volunter project. +from unipath import Path + + +PROJECT_DIR = Path(__file__).parent DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -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': '', @@ -50,18 +53,18 @@ # 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/" @@ -69,9 +72,7 @@ # 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 @@ -79,7 +80,7 @@ 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. @@ -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 = ( @@ -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". @@ -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 diff --git a/volunter/volunteer/urls.py b/volunter/volunteer/urls.py new file mode 100644 index 0000000..56d37d7 --- /dev/null +++ b/volunter/volunteer/urls.py @@ -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)), +) diff --git a/volunter/volunter/wsgi.py b/volunter/volunteer/wsgi.py similarity index 95% rename from volunter/volunter/wsgi.py rename to volunter/volunteer/wsgi.py index 47c6a8e..ac6693a 100644 --- a/volunter/volunter/wsgi.py +++ b/volunter/volunteer/wsgi.py @@ -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 diff --git a/volunter/volunter/app/core/models.py b/volunter/volunter/app/core/models.py deleted file mode 100644 index 71a8362..0000000 --- a/volunter/volunter/app/core/models.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/volunter/volunter/urls.py b/volunter/volunter/urls.py deleted file mode 100644 index 2525aea..0000000 --- a/volunter/volunter/urls.py +++ /dev/null @@ -1,17 +0,0 @@ -from django.conf.urls import patterns, include, url - -# Uncomment the next two lines to enable the admin: -# from django.contrib import admin -# admin.autodiscover() - -urlpatterns = patterns('', - # Examples: - # url(r'^$', 'volunter.views.home', name='home'), - # url(r'^volunter/', include('volunter.foo.urls')), - - # Uncomment the admin/doc line below to enable admin documentation: - # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - - # Uncomment the next line to enable the admin: - # url(r'^admin/', include(admin.site.urls)), -)