Created
March 19, 2015 20:40
-
-
Save wess/c6486b19b7d0c2c1e398 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# company/models.py | |
from django.conf import settings | |
from django.db import models | |
from diagnose.models import IdentityModel | |
from users.models import User | |
class Company(IdentityModel): | |
name = models.CharField(max_length=200) | |
website = models.URLField() | |
logo = models.FileField() | |
owner = models.OneToOneField("users.User", related_name='company') | |
# disciplines/models.py | |
from django.db import models | |
from diagnose.models import BaseModel | |
class Discipline(BaseModel): | |
company = models.ForeignKey('company.Company', related_name='disciplines') | |
name = models.CharField(max_length=200) | |
description = models.CharField(max_length=200) | |
sort_order = models.PositiveIntegerField(default=1) | |
is_active = models.BooleanField(default=True) | |
# BaseModel | |
class BaseModel(models.Model): | |
logs = generic.GenericRelation('logs.Log') | |
updated_on = models.DateTimeField(auto_now=True) | |
created_on = models.DateTimeField(auto_now_add=True) | |
class Meta: | |
abstract = True | |
get_latest_by = 'updated_on' | |
# View Code | |
d = Discipline.objects.get(id=int(discipline_id), company=company) | |
d.delete() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment