forked from pug-se/labdjango
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add models and rename project. pug-se#1
- Loading branch information
Showing
14 changed files
with
85 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.