Models for software projects¶
django-project-portfolio
provides three models which work together
to describe software projects: Project
represents a software
project, Version
represents a particular version of a
project, and License
represents the license under which a
particular version is released.
-
class
projects.models.
License
¶ The license under which a particular
Version
is released. This is tied toVersion
rather thanProject
in order to allow the possibility of relicensing from one version to another.A
License
has three fields, all of which are required:-
name
¶ CharField(max_length=255)
The name of the license (for example, “GPLv2” or “MIT”).
-
slug
¶ SlugField
(prepopulated fromname
)A short, descriptive URL-safe string to identify the license. Currently there are no views in
django-project-portfolio
which make use of this, but the field is provided so that custom views can make use of it.
-
link
¶ URLField
A link to an online version of the license’s terms, or to a description of the license. For open-source licenses, individual license pages in the OSI license list are useful values for this field.
-
-
class
projects.models.
Project
¶ A software project.
Four fields (all required) provide basic metadata about the project:
-
name
¶ CharField(max_length=255)
The name of the project.
-
slug
¶ SlugField
(prepopulated fromname
)A short, descriptive URL-safe string to identify the project.
-
description
¶ TextField
A free-form text description of the project.
-
status
¶ IntegerField
with choicesIndicates whether the project is public or not. May be expanded to include additional options in future versions, hence the implementation as an
IntegerField
with choices instead of aBooleanField
. Valid choices are:
-
PUBLIC_STATUS
¶ Indicates a project which is public; this will cause built-in views to list and display the project.
-
HIDDEN_STATUS
¶ Indicates a project which is hidden; built-in views will not list or display the project.
Four additional fields, all optional, allow additional useful data about the project to be specified:
-
package_link
¶ URLField
URL of a location where packages for this project can be found.
-
repository_link
¶ URLField
URL of the project’s source-code repository.
-
documentation_link
¶ URLField
URL of the project’s online documentation.
-
tests_link
¶ URLField
URL of the project’s online testing/continuous integration status.
One utility method is also defined on instances of
Project
:-
latest_version
()¶ Returns the latest
Version
of this project (as defined by theis_latest
field onVersion
), orNone
if no such version exists.
Finally, the default manager for
Project
defines one custom query method,public()
, which returns only instances whosestatus
isPUBLIC_STATUS
. This is implemented via a customQuerySet
subclass, so the method will be available on anyQuerySet
obtained fromProject
as well.-
-
class
projects.models.
Version
¶ A particular version of a software project.
There are six fields, all of which are required:
-
version
¶ CharField(max_length=255)
A string representing the version’s identifier. This is deliberately freeform to support different types of versioning systems, but be aware that it will (with the built-in views) be used in URLs, so URL-safe strings are encouraged here.
-
is_latest
¶ BooleanField
Indicates whether this is the latest version of the project. When a
Version
is saved withis_latest=True
, apost_save
signal handler will toggle all other versions of thatProject
tois_latest=False
.
-
status
¶ IntegerField
with choicesThe status of this version. Valid choices are (taken from the Python Package Index’s status choices):
-
PLANNING_STATUS
¶ This is an early/planning version.
-
PRE_ALPHA_STATUS
¶ This is a pre-alpha version.
-
ALPHA_STATUS
¶ This is an alpha version.
-
BETA_STATUS
¶ This is a beta version.
-
STABLE_STATUS
¶ This is a stable version.
-
release_date
¶ The date on which this version was released.
Additionally, the default manager for
Version
defines one custom query method,stable()
, which returns only instances whosestatus
isSTABLE_STATUS
. This is implemented via a customQuerySet
subclass, so the method will be available on anyQuerySet
obtained fromVersion
as well, and also on any relatedQuerySet
obtained through an instance ofProject
.-