Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moving todo's into the code in order that the IDE will pick them up...

  • Loading branch information...
commit ea66e5c14894dd2e2eb40b26c4d98c65630c2610 1 parent 0454f87
@sebinsua authored
View
328 architecture/database/latest.sql
@@ -4,148 +4,148 @@
BEGIN;
CREATE TABLE "User" (
- user_id serial,
- uuid varchar(100) NOT NULL,
- email text NOT NULL,
- username text NOT NULL,
- password_hash char(60) NOT NULL,
- first_name varchar(100),
- last_name varchar(100),
- gender char(1),
- date_of_birth date,
- summary text,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (user_id),
- UNIQUE (uuid),
- UNIQUE (email),
- UNIQUE (username)
+ user_id serial,
+ uuid varchar(100) NOT NULL,
+ email text NOT NULL,
+ username text NOT NULL,
+ password_hash char(60) NOT NULL,
+ first_name varchar(100),
+ last_name varchar(100),
+ gender char(1),
+ date_of_birth date,
+ summary text,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (user_id),
+ UNIQUE (uuid),
+ UNIQUE (email),
+ UNIQUE (username)
);
-- e.g. Remixer, Group/Band, Artist, Songwriter, Producer, Guitarist, etc.
CREATE TABLE "AgentType" (
- agent_type_id serial,
- name varchar(50) NOT NULL,
- PRIMARY KEY (agent_type_id),
- UNIQUE (name)
+ agent_type_id serial,
+ name varchar(50) NOT NULL,
+ PRIMARY KEY (agent_type_id),
+ UNIQUE (name)
);
CREATE TABLE "Agent" (
- agent_id serial,
- agent_type_id integer NOT NULL,
- musicbrainz_mbid char(36),
- name text NOT NULL,
- sort_name varchar(50),
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (agent_id),
- UNIQUE (name),
- FOREIGN KEY (agent_type_id) REFERENCES "AgentType"
+ agent_id serial,
+ agent_type_id integer NOT NULL,
+ musicbrainz_mbid char(36),
+ name text NOT NULL,
+ sort_name varchar(50),
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (agent_id),
+ UNIQUE (name),
+ FOREIGN KEY (agent_type_id) REFERENCES "AgentType"
);
-- NOTE: Agent groupings won't be used yet.
CREATE TABLE "AgentAgent" (
- agent_agent_id serial,
- parent_agent_id integer NOT NULL,
- child_agent_id integer NOT NULL,
- start_date timestamp,
- end_date timestamp,
- PRIMARY KEY (agent_agent_id),
- FOREIGN KEY (parent_agent_id) REFERENCES "Agent" (agent_id),
- FOREIGN KEY (child_agent_id) REFERENCES "Agent" (agent_id)
+ agent_agent_id serial,
+ parent_agent_id integer NOT NULL,
+ child_agent_id integer NOT NULL,
+ start_date timestamp,
+ end_date timestamp,
+ PRIMARY KEY (agent_agent_id),
+ FOREIGN KEY (parent_agent_id) REFERENCES "Agent" (agent_id),
+ FOREIGN KEY (child_agent_id) REFERENCES "Agent" (agent_id)
);
-- e.g. User is following an artist.
CREATE TABLE "UserAgent" (
- user_agent_id serial,
- user_id integer NOT NULL,
- agent_id integer NOT NULL,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (user_agent_id),
- FOREIGN KEY (user_id) REFERENCES "User",
- FOREIGN KEY (agent_id) REFERENCES "Agent"
+ user_agent_id serial,
+ user_id integer NOT NULL,
+ agent_id integer NOT NULL,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (user_agent_id),
+ FOREIGN KEY (user_id) REFERENCES "User",
+ FOREIGN KEY (agent_id) REFERENCES "Agent"
);
--- TODO: A nicer way of storing fuzzy temporal data?
+-- @todo: A nicer way of storing fuzzy temporal data?
CREATE TABLE "Event" (
- event_id serial,
- predicted_start_release_date timestamp,
- predicted_end_release_date timestamp,
- predicted_textual_release_date bytea,
- certainty integer,
- PRIMARY KEY (event_id)
+ event_id serial,
+ predicted_start_release_date timestamp,
+ predicted_end_release_date timestamp,
+ predicted_textual_release_date bytea,
+ certainty integer,
+ PRIMARY KEY (event_id)
);
-- e.g. Digital, CD, DVD, Cassette, Vinyl.
CREATE TABLE "ProductMedium" (
- product_medium_id serial,
- name varchar(50) NOT NULL,
- PRIMARY KEY (product_medium_id),
- UNIQUE (name)
+ product_medium_id serial,
+ name varchar(50) NOT NULL,
+ PRIMARY KEY (product_medium_id),
+ UNIQUE (name)
);
-- e.g. Album, EP, Single.
CREATE TABLE "ProductType" (
- product_type_id serial,
- name varchar(50) NOT NULL,
- PRIMARY KEY (product_type_id),
- UNIQUE (name)
+ product_type_id serial,
+ name varchar(50) NOT NULL,
+ PRIMARY KEY (product_type_id),
+ UNIQUE (name)
);
-- e.g. Official, Promotional, Bootleg.
CREATE TABLE "ProductStatus" (
- product_status_id serial,
- name varchar(50) NOT NULL,
- PRIMARY KEY (product_status_id),
- UNIQUE (name)
+ product_status_id serial,
+ name varchar(50) NOT NULL,
+ PRIMARY KEY (product_status_id),
+ UNIQUE (name)
);
-- e.g. Boxset, US Tour, etc.
CREATE TABLE "Work" (
- work_id serial,
- title text NOT NULL,
- sort_title varchar(50),
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (work_id)
+ work_id serial,
+ title text NOT NULL,
+ sort_title varchar(50),
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (work_id)
);
-- e.g. Album, etc.
CREATE TABLE "Product" (
- product_id serial,
- work_id integer,
- product_type_id integer NOT NULL,
- product_status_id integer NOT NULL,
- product_medium_id integer,
- event_id integer NOT NULL,
- title text NOT NULL,
- sort_title varchar(50),
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (product_id),
- FOREIGN KEY (work_id) REFERENCES "Work",
- FOREIGN KEY (product_type_id) REFERENCES "ProductType",
- FOREIGN KEY (product_status_id) REFERENCES "ProductStatus",
- FOREIGN KEY (product_medium_id) REFERENCES "ProductMedium",
- FOREIGN KEY (event_id) REFERENCES "Event"
+ product_id serial,
+ work_id integer,
+ product_type_id integer NOT NULL,
+ product_status_id integer NOT NULL,
+ product_medium_id integer,
+ event_id integer NOT NULL,
+ title text NOT NULL,
+ sort_title varchar(50),
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (product_id),
+ FOREIGN KEY (work_id) REFERENCES "Work",
+ FOREIGN KEY (product_type_id) REFERENCES "ProductType",
+ FOREIGN KEY (product_status_id) REFERENCES "ProductStatus",
+ FOREIGN KEY (product_medium_id) REFERENCES "ProductMedium",
+ FOREIGN KEY (event_id) REFERENCES "Event"
);
-- e.g. Live Performance.
CREATE TABLE "ServiceType" (
- service_type_id serial,
- name varchar(50) NOT NULL,
- PRIMARY KEY (service_type_id),
- UNIQUE (name)
+ service_type_id serial,
+ name varchar(50) NOT NULL,
+ PRIMARY KEY (service_type_id),
+ UNIQUE (name)
);
CREATE TABLE "Service" (
- service_id serial,
- work_id integer,
- service_type_id integer,
- event_id integer NOT NULL,
- title text NOT NULL,
- sort_title varchar(50),
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (service_id),
- FOREIGN KEY (work_id) REFERENCES "Work",
- FOREIGN KEY (service_type_id) REFERENCES "ServiceType",
- FOREIGN KEY (event_id) REFERENCES "Event"
+ service_id serial,
+ work_id integer,
+ service_type_id integer,
+ event_id integer NOT NULL,
+ title text NOT NULL,
+ sort_title varchar(50),
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (service_id),
+ FOREIGN KEY (work_id) REFERENCES "Work",
+ FOREIGN KEY (service_type_id) REFERENCES "ServiceType",
+ FOREIGN KEY (event_id) REFERENCES "Event"
);
-- NOTE: Both ProductAgent and ServiceAgent show participation:
@@ -154,96 +154,96 @@ CREATE TABLE "Service" (
-- addition to agent_type_id to help distinguish agents.
-- ProductAgent contains the artists against a product...
CREATE TABLE "ProductAgent" (
- product_agent_id serial,
- product_id integer NOT NULL,
- agent_id integer NOT NULL,
- agent_order integer,
- agent_type_id integer,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (product_agent_id),
- FOREIGN KEY (product_id) REFERENCES "Product",
- FOREIGN KEY (agent_id) REFERENCES "Agent",
- FOREIGN KEY (agent_type_id) REFERENCES "AgentType"
+ product_agent_id serial,
+ product_id integer NOT NULL,
+ agent_id integer NOT NULL,
+ agent_order integer,
+ agent_type_id integer,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (product_agent_id),
+ FOREIGN KEY (product_id) REFERENCES "Product",
+ FOREIGN KEY (agent_id) REFERENCES "Agent",
+ FOREIGN KEY (agent_type_id) REFERENCES "AgentType"
);
-- ServiceAgent contains the artists against a service (performance, etc.)
CREATE TABLE "ServiceAgent" (
- service_agent_id serial,
- service_id integer NOT NULL,
- agent_id integer NOT NULL,
- agent_order integer,
- agent_type_id integer,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (service_agent_id),
- FOREIGN KEY (service_id) REFERENCES "Service",
- FOREIGN KEY (agent_id) REFERENCES "Agent",
- FOREIGN KEY (agent_type_id) REFERENCES "AgentType"
+ service_agent_id serial,
+ service_id integer NOT NULL,
+ agent_id integer NOT NULL,
+ agent_order integer,
+ agent_type_id integer,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (service_agent_id),
+ FOREIGN KEY (service_id) REFERENCES "Service",
+ FOREIGN KEY (agent_id) REFERENCES "Agent",
+ FOREIGN KEY (agent_type_id) REFERENCES "AgentType"
);
CREATE TABLE "UserEvent" (
- user_event_id serial,
- user_id integer NOT NULL,
- event_id integer NOT NULL,
- start_release_date timestamp,
- end_release_date timestamp,
- textual_release_date bytea,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (user_event_id),
- FOREIGN KEY (user_id) REFERENCES "User",
- FOREIGN KEY (event_id) REFERENCES "Event"
+ user_event_id serial,
+ user_id integer NOT NULL,
+ event_id integer NOT NULL,
+ start_release_date timestamp,
+ end_release_date timestamp,
+ textual_release_date bytea,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (user_event_id),
+ FOREIGN KEY (user_id) REFERENCES "User",
+ FOREIGN KEY (event_id) REFERENCES "Event"
);
CREATE TABLE "UserProduct" (
- user_product_id serial,
- user_id integer NOT NULL,
- product_id integer NOT NULL,
- weight integer NOT NULL DEFAULT 50,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (user_product_id),
- FOREIGN KEY (user_id) REFERENCES "User",
- FOREIGN KEY (product_id) REFERENCES "Product"
+ user_product_id serial,
+ user_id integer NOT NULL,
+ product_id integer NOT NULL,
+ weight integer NOT NULL DEFAULT 50,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (user_product_id),
+ FOREIGN KEY (user_id) REFERENCES "User",
+ FOREIGN KEY (product_id) REFERENCES "Product"
);
CREATE TABLE "UserService" (
- user_service_id serial,
- user_id integer NOT NULL,
- service_id integer NOT NULL,
- weight integer NOT NULL DEFAULT 50,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (user_service_id),
- FOREIGN KEY (user_id) REFERENCES "User",
- FOREIGN KEY (service_id) REFERENCES "Service"
+ user_service_id serial,
+ user_id integer NOT NULL,
+ service_id integer NOT NULL,
+ weight integer NOT NULL DEFAULT 50,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (user_service_id),
+ FOREIGN KEY (user_id) REFERENCES "User",
+ FOREIGN KEY (service_id) REFERENCES "Service"
);
CREATE TABLE "ContentOwner" (
- content_owner_id serial,
- name text NOT NULL,
- sort_name varchar(50),
- start_date date,
- end_date date,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (content_owner_id),
- UNIQUE (name, start_date, end_date)
+ content_owner_id serial,
+ name text NOT NULL,
+ sort_name varchar(50),
+ start_date date,
+ end_date date,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (content_owner_id),
+ UNIQUE (name, start_date, end_date)
);
-- e.g. Label, Distributor, Holding, Original Production, Bootleg Production, etc.
CREATE TABLE "ContentOwnerProductType" (
- content_owner_product_type_id serial,
- name varchar(50),
- PRIMARY KEY (content_owner_product_type_id),
- UNIQUE (name)
+ content_owner_product_type_id serial,
+ name varchar(50),
+ PRIMARY KEY (content_owner_product_type_id),
+ UNIQUE (name)
);
CREATE TABLE "ContentOwnerProduct" (
- content_owner_product_id serial,
- content_owner_id integer NOT NULL,
- product_id integer NOT NULL,
- content_owner_product_type_id integer,
- created timestamp NOT NULL DEFAULT current_timestamp,
- PRIMARY KEY (content_owner_product_id),
- FOREIGN KEY (content_owner_id) REFERENCES "ContentOwner",
- FOREIGN KEY (product_id) REFERENCES "Product",
- FOREIGN KEY (content_owner_product_type_id) REFERENCES "ContentOwnerProductType"
+ content_owner_product_id serial,
+ content_owner_id integer NOT NULL,
+ product_id integer NOT NULL,
+ content_owner_product_type_id integer,
+ created timestamp NOT NULL DEFAULT current_timestamp,
+ PRIMARY KEY (content_owner_product_id),
+ FOREIGN KEY (content_owner_id) REFERENCES "ContentOwner",
+ FOREIGN KEY (product_id) REFERENCES "Product",
+ FOREIGN KEY (content_owner_product_type_id) REFERENCES "ContentOwnerProductType"
);
COMMIT;
View
30 modules/app/__init__.py
@@ -10,6 +10,36 @@ def inject_user():
return dict(user=user.to_dict())
return dict()
+# What would make this usable for me and others?
+# @todo: Get Gravatar working as fallback. ;)
+# @todo: Dropdown on the account button and boxed. Points to View Profile, Edit Account pages.
+# @todo: ACL.
+# @todo: Database design for how often I wish to be notified?
+# ---
+# @todo: Change the order of the mediums, statuses, types, etc.
+# @todo: Add Release, Album, EP, etc. should alter the selected default.
+# @todo: Valid time periods are stored inside a special class. Version. Validate against this, and use to store correctly.
+# @todo: View/Edit Artist, View/Edit Release.
+# @todo: Database design for some kind of tag/genre grouping of services and releases.
+# @todo: Order new releases by modified event date.
+# @todo: Bulk automation.
+# @todo: Visualisation on the front page. How do I create useful categories for data?
+# @todo: Never-ending list on New Releases page.
+# @todo: last.fm or theechonest photo/synopsis for artists/releases.
+# ---
+# @todo: Voting is added. Popularity becomes a category.
+# @todo: Work out how altering the event date mechanism will work.
+# ---
+# @todo: Design and implement searching mechanism.
+# ---
+# @todo: OAuth. Facebook Connect.
+# @todo: RSS.
+# @todo: Services.
+# ---
+# @todo: FIX THIS: Lazy loading is very slow if it happens over and over again.
+# ---
+# @todo: UX: Add, Edit, Remove, Browse, View, Filter. Admin Features? Navigation?
+
from helper.controller import register_controller_blueprints
# "import controller" calls initialise which runs some special code that
# automatically loads each of the python files inside the controller folder.
View
13 modules/app/model/domain/product.py
@@ -9,11 +9,9 @@ def add_product(agent_name, agent_type_id, event_release_date, \
product_title, product_type_id=None, product_status_id=None, \
product_medium_id=None, content_owner_name=None):
- # TODO: Normalize content owner and agents. Don't insert redundant data.
-
# Add an Event
from mu.model.entity.event import Event
- # TODO: Pick the correct release date field depending on the data.
+ # @todo: Pick the correct release date field depending on the data.
event = Event(predicted_textual_release_date=event_release_date)
event_id = add_event(event)
@@ -24,9 +22,8 @@ def add_product(agent_name, agent_type_id, event_release_date, \
# Add an Agent
from mu.model.entity.agent import Agent, AgentType
- # TODO: musicbrainz_mbid, start_date and end_date can be None or fetched from musicbrainz.
+ # @todo: musicbrainz_mbid, start_date and end_date can be None or fetched from musicbrainz.
agent = Agent(agent_name, agent_type_id)
- # TODO: How do we get the agent_id if the agent already exists?
agent_id = add_agent(agent)
link_product_to_agent(agent_id, product_id, agent_type_id)
@@ -34,8 +31,7 @@ def add_product(agent_name, agent_type_id, event_release_date, \
if content_owner_name:
from mu.model.entity.content_owner import ContentOwner
content_owner = ContentOwner(content_owner_name)
- # TODO: start_date, end_date can be none or fetched from musicbrainz.
- # TODO: How do we get the content_owner_id if the content_owner already exists!
+ # @todo: start_date, end_date can be none or fetched from musicbrainz.
content_owner_id = add_content_owner(content_owner)
link_product_to_content_owner(content_owner_id, product_id)
@@ -47,8 +43,7 @@ def add_product(agent_name, agent_type_id, event_release_date, \
@staticmethod
def get_products(product_type=None):
# Accept plural but convert to singular...
- # todo: Is this necessary?!
- if product_type and product_type.endswith('s'):
+ if product_type and product_type.endswith('s'): # urls are pluralised but data is singular!
product_type = product_type[:-1]
if product_type in ['release', 'product']:
product_type = None # We want to get everything out in this case.
View
2  modules/app/templates/home.html
@@ -6,7 +6,7 @@
<div class="container">
<div class="hero-unit">
<h1>Welcome{% if user %} {{ user.username }}{% endif %}.</h1>
- <p>Have fun on the site. :)</p>
+ <p class="lead">When will something happen?</p>
</div>
</div>
{% endblock %}
View
15 modules/helper/database.py
@@ -1,4 +1,4 @@
-# TODO: What do we gain by not using everything directly?
+# @todo: What do we gain by not using everything directly?
# Is this legacy? When should the db be setup? Will it be helpful to create
# helper methods for myself?
@@ -10,6 +10,8 @@
from sqlalchemy.sql.expression import func, and_
def check_if_entity_exists(entity):
+ from helper.db import db
+
entity_unique_constraints = entity.get_constraints_by_type(db.UniqueConstraint)
# Check to see whether the values inside this list of columns already exists in the database
# using a where key1 = agent.key1 and key2 = agent.key2 and key3 = agent.key3
@@ -18,22 +20,31 @@ def check_if_entity_exists(entity):
for constraint_columns in entity_unique_constraints:
filter_clauses = []
for constraint_column_name in constraint_columns:
- filter_clauses.append(getattr(entity.__class__, constraint_column_name)==getattr(entity, constraint_column_name))
+ filter_clauses.append(
+ getattr(entity.__class__, constraint_column_name) == getattr(entity, constraint_column_name))
query = db.session.query(entity.__class__).filter(and_(*filter_clauses))
# http://stackoverflow.com/questions/7092396/react-on-uniquekeyviolation-in-sqlalchemy
from sqlalchemy.orm.exc import NoResultFound
+
try:
return query.one()
except NoResultFound:
pass
return None
+
class LowerCaseComparator(ColumnProperty.Comparator):
def __eq__(self, other):
return func.lower(self.__clause_element__()) == func.lower(other)
+
class ConstraintsMixin(object):
+ '''
+ This class will never be used on its own. It will always be used with SQLAlchemy declarative_base classes
+ to add extra functionality relating to fetching columns that are part of a particular type of constraint.
+ '''
+
def get_constraints_by_type(self, ConstraintClass=None):
constraint_columns = []
for constraint in self.__table__.constraints:
View
17 todo
@@ -1,17 +0,0 @@
-01. FIX THIS: Lazy loading is very slow if it happens over and over again.
-----
-02. UX: Add, Edit, Remove, Browse, View, Filter. Admin Features? Navigation?
-03. Pagination?
-04. Bulk Import.
-----
-05. User Roles: ACL. Edit Account, Edit Profile.
-06. Voting/unvoting.
-----
-07. Define different time periods, etc. Classify. Version.
-----
-08. RSS of updated releases by a filter...
-09. Emails based off this RSS/filter.
-10. Abiilty for users to add events. Vote on these?
-----
-11. OAuth / Facebook Connect.
-12. Work the API feeds that I have available to me...
Please sign in to comment.
Something went wrong with that request. Please try again.