Пример #1
0
class Street(models.Model):
    """
    Represents a street in a city that will be used in addresses for
    organizations and personal addresses.
    """
    name = cmf.RequiredCharField(max_length=50)
    city = cmf.RequiredForeignKey(City)
Пример #2
0
class ProfessionalProject(models.Model):

    name = cmf.RequiredCharField(max_length=100)
    description = cmf.RequiredTextField(max_length=300)
    employment = cmf.RequiredForeignKey(Employment)

    github_link = models.CharField(max_length=100)
Пример #3
0
class City(models.Model):
    """
    Represents a city in a region that will be used in addresses for
    organizations and personal addresses.
    """
    name = cmf.RequiredCharField(max_length=50)
    region = cmf.RequiredForeignKey(Region)
Пример #4
0
class Region(models.Model):
    """
    Represents a region in a country that will be used in addresses for
    organizations and personal addresses.

    A region can be any one of the following types:
        - State (example: U.S. states)
        - Region
        - Province (example: old France regional breakdown)
    """
    REGION_TYPES = (("ST", "State"), ("RE", "Region"), ("PR", "Province"))

    name = cmf.RequiredCharField(max_length=50)
    region_type = cmf.RequiredCharField(max_length=2,
                                        choices=REGION_TYPES,
                                        default="ST")
    country = cmf.RequiredForeignKey(Country)

    def region_type_to_string(self):
        return dict(self.REGION_TYPES)[self.region_type]

    @classmethod
    def crud_api_view(cls):
        return model_crud_api_view_factory(cls)

    def json(self):
        """
        Returns a json representation of this object.
        See "styleguides/CODe_STYLE.md" for more information on this method.
        """
        return {
            "name": self.name,
            "region_type": self.region_type_to_string(),
            "country": self.country.json()
        }
Пример #5
0
class Organization(models.Model):
    """
    Represents an organization used to record experience history for a user and
    where he or she has worked or volunteered.
    """
    name = cmf.RequiredCharField(max_length=50)
    website_homepage = models.CharField(max_length=200)
    hq_address = cmf.RequiredForeignKey(Address)
Пример #6
0
class Address(models.Model):
    """
    Represents a location of a building for an organization or a personal
    address.

    To get city, state and contry, use street. This class is related to those
    instances indirectly through street.

    For example, to get the country of this address, call
    "street.city.region.country".
    """
    building_number = cmf.RequiredIntegerField()
    street = cmf.RequiredForeignKey(Street)
Пример #7
0
class Involvement(models.Model):

    description = cmf.RequiredTextField(max_length=500)
    organization = cmf.RequiredForeignKey(Organization)
Пример #8
0
class Employment(models.Model):

    title = cmf.RequiredCharField(max_length=50)
    organization = cmf.RequiredForeignKey(Organization)
    description = cmf.RequiredTextField(max_length=500)