Commits

Kevin Veroneau committed 8ce5000 Draft

Added initial data models for prototype development.

Comments (0)

Files changed (7)

+from django.contrib import admin
+from gamedb.models import Game, GameDownload, EngineVersion, CustomComment,\
+    Writer, Artist, Composer, Screenshot
+
+admin.site.register(Game)
+admin.site.register(GameDownload)
+admin.site.register(EngineVersion)
+admin.site.register(CustomComment)
+admin.site.register(Writer)
+admin.site.register(Artist)
+admin.site.register(Composer)
+admin.site.register(Screenshot)
+'''
+Created on May 10, 2013
+
+@author: kveroneau
+'''
 from django.db import models
+from django.contrib.auth.models import User
+from django.utils.text import slugify
 
-# Create your models here.
+class CustomComment(models.Model):
+    owner = models.ForeignKey(User)
+    username = models.CharField(max_length=80, blank=True)
+    comment = models.TextField()
+    posted = models.DateTimeField(auto_now_add=True)
+    def __unicode__(self):
+        return u"%s" % self.username
+    def save(self, commit=True):
+        self.username = self.owner.username
+        return super(CustomComment, self).save(commit)
+
+class EngineVersion(models.Model):
+    codename = models.CharField(max_length=60, help_text='Codename for this version of the game engine.')
+    released_on = models.DateField()
+    version = models.DecimalField(blank=True, null=True, max_digits=4, decimal_places=2, help_text='Decimal version number of this version.')
+    def __unicode__(self):
+        return u"%s" % self.codename
+
+class Writer(models.Model):
+    owner = models.ForeignKey(User, blank=True, null=True, help_text='Is this writer part of this community?')
+    known_as = models.CharField(max_length=80, blank=True, help_text='What name does this writer go by?  Leave blank to use username.')
+    bio = models.TextField(blank=True, help_text='Optional, but highly recommended.')
+    def __unicode__(self):
+        return u"%s" % self.known_as
+    def save(self, commit=True):
+        if self.known_as == '':
+            self.known_as = self.owner.username
+        return super(Writer, self).save(commit)
+
+class Artist(models.Model):
+    owner = models.ForeignKey(User, blank=True, null=True, help_text='Is this artist part of this community?')
+    known_as = models.CharField(max_length=80, blank=True, help_text='What name does this artist go by?  Leave blank to use username.')
+    bio = models.TextField(blank=True, help_text='Optional, but highly recommended.')
+    website = models.URLField(blank=True, help_text='Does this artist have a online portfolio somewhere?')
+    def __unicode__(self):
+        return u"%s" % self.known_as
+    def save(self, commit=True):
+        if self.known_as == '':
+            self.known_as = self.owner.username
+        return super(Artist, self).save(commit)
+
+class Composer(models.Model):
+    owner = models.ForeignKey(User, blank=True, null=True, help_text='Is this composer part of this community?')
+    known_as = models.CharField(max_length=80, blank=True, help_text='What name does this composer go by?  Leave blank to use username.')
+    bio = models.TextField(blank=True, help_text='Optional, but highly recommended.')
+    website = models.URLField(blank=True, help_text='Does this composer have a online portfolio somewhere?')
+    def __unicode__(self):
+        return u"%s" % self.known_as
+    def save(self, commit=True):
+        if self.known_as == '':
+            self.known_as = self.owner.username
+        return super(Composer, self).save(commit)
+
+class GameDownload(models.Model):
+    GAME_WORKFLOW = (
+        (10, 'Draft'),
+        (20, 'Demo'),
+        (30, 'Alpha'),
+        (40, 'Beta'),
+        (200, 'Final'),
+    )
+    game_file = models.FileField(upload_to='games')
+    title = models.CharField(max_length=128)
+    version = models.PositiveIntegerField()
+    classification = models.PositiveSmallIntegerField(choices=GAME_WORKFLOW, help_text='What classification does this release fall under?')
+    is_public = models.BooleanField(default=True, help_text='Can anyone download this version?')
+    beta_testers = models.ManyToManyField(User, blank=True, null=True, help_text='If this is not a public release, choose users who do have access.')
+    changelog = models.TextField(blank=True, help_text='Detail any changes you may have done in this version -- optional.')
+    download_count = models.PositiveIntegerField(default=0)
+    release_date = models.DateField(auto_now_add=True)
+    def __unicode__(self):
+        return "%s %s %s" % (self.title, self.version, self.get_classification_display())
+
+class Screenshot(models.Model):
+    title = models.CharField(max_length=128, help_text='A title for this image?')
+    is_public = models.BooleanField(default=True)
+    is_title = models.BooleanField(help_text='Is this a title screen for the game?')
+    added_on = models.DateField(auto_now_add=True)
+    def __unicode__(self):
+        return u"%s" % self.title
+
+class Game(models.Model):
+    TYPE_LIST = (
+        (10, 'RPG Game'),
+        (20, 'Platformer'),
+        (30, 'Tech Demo'),
+        (40, 'Simulation'),
+        (50, 'Strategy'),
+        (200, 'Other'),
+    )
+    GENRE_LIST = (
+        (30, 'Adventure'),
+        (40, 'Horror'),
+        (50, 'Humor'),
+        (60, 'Parody'),
+        (70, 'Fan Game'),
+        (200, 'Other'),
+    )
+    STYLE_LIST = (
+        ('Console styles', (
+            (10, 'Old School NES'),
+            (20, 'Old School SNES'),
+        )),
+        ('Unique Contrasts', (
+            (30, 'Low contrast'),
+            (40, 'Bright and colorful'),
+            (50, '2 color'),
+            (60, 'Shades of gray'),
+            (70, 'Cartoon like'),
+        )),
+    )
+    title = models.CharField(max_length=128, help_text='Enter the title for your game here.')
+    slug = models.SlugField(blank=True)
+    owner = models.ForeignKey(User)
+    author = models.CharField(max_length=80, blank=True)
+    description = models.TextField(help_text='A description of your game to let others know what they will be playing.  Be creative!')
+    game_type = models.PositiveSmallIntegerField(choices=TYPE_LIST, help_text='Where does your game best fit in?')
+    genre = models.PositiveSmallIntegerField(choices=GENRE_LIST, help_text='What genre is this game?')
+    style = models.PositiveSmallIntegerField(choices=STYLE_LIST, help_text='What graphical style does your game use?')
+    storyline = models.TextField(help_text='The introduction story of your game, different than the description.')
+    scenario = models.ManyToManyField(Writer, help_text='Who wrote the scenario/story for this game?')
+    graphics = models.ManyToManyField(Artist, help_text='Who drew the graphics you used in your game?')
+    music = models.ManyToManyField(Composer, related_name='game_music_list', help_text='Who composed the music you used in your game?')
+    sfx = models.ManyToManyField(Composer, related_name='game_sfx_list', help_text='Who created the sound effects you used in your game?')
+    downloads = models.ManyToManyField(GameDownload, blank=True, null=True)
+    screenshots = models.ManyToManyField(Screenshot, blank=True, null=True)
+    engine = models.ForeignKey(EngineVersion, help_text='Which version of the engine was used to develop this game?')
+    download_count = models.PositiveIntegerField(default=0)
+    comments = models.ManyToManyField(CustomComment, blank=True, null=True)
+    liked_by = models.ManyToManyField(User, blank=True, null=True, related_name='games_liked')
+    disliked_by = models.ManyToManyField(User, blank=True, null=True, related_name='games_disliked')
+    date_added = models.DateField(auto_now_add=True)
+    updated_on = models.DateField(auto_now=True)
+    def __unicode__(self):
+        return u"%s" % self.title
+    def save(self, commit=True):
+        if self.slug == '':
+            self.slug = slugify(self.title)
+        if self.author == '':
+            self.author = self.owner.username
+        return super(Game, self).save(commit)

gamedb/templatetags/__init__.py

Empty file added.
+from django.conf.urls import patterns, url
+from django.views.generic.base import TemplateView
+
+urlpatterns = patterns('',
+    url(r'^$', TemplateView.as_view(template_name='base.html')),
+)
+import os.path
+PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)+'/..')
+
+# Django settings for ohr project.
+
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+INTERNAL_IPS = ('127.0.0.1',)
+
+ADMINS = (
+    ('Your Name', 'your_email@example.com'),
+)
+
+MANAGERS = ADMINS
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+        'NAME': os.path.join(PROJECT_ROOT, 'sqlite.db'),                      # Or path to database file if using sqlite3.
+        # The following settings are not used with sqlite3:
+        'USER': '',
+        'PASSWORD': '',
+        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
+        'PORT': '',                      # Set to empty string for default.
+    }
+}
+
+# Hosts/domain names that are valid for this site; required if DEBUG is False
+# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
+ALLOWED_HOSTS = []
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# In a Windows environment this must be set to your system time zone.
+TIME_ZONE = 'America/Winnipeg'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = False
+
+# If you set this to False, Django will not format dates, numbers and
+# calendars according to the current locale.
+USE_L10N = True
+
+# If you set this to False, Django will not use timezone-aware datetimes.
+USE_TZ = False
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/var/www/example.com/media/"
+MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://example.com/media/", "http://media.example.com/"
+MEDIA_URL = 'http://localhost:8080/'
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/var/www/example.com/static/"
+STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
+
+# URL prefix for static files.
+# Example: "http://example.com/static/", "http://static.example.com/"
+STATIC_URL = '/s/'
+
+# Additional locations of static files
+STATICFILES_DIRS = (
+    os.path.join(PROJECT_ROOT, 'bootstrap'),
+    os.path.join(PROJECT_ROOT, 'jquery'),
+    os.path.join(PROJECT_ROOT, 'assets'),
+)
+
+# List of finder classes that know how to find static files in
+# various locations.
+STATICFILES_FINDERS = (
+    'django.contrib.staticfiles.finders.FileSystemFinder',
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
+)
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = '3q&emz8w5r@i1a%$%q(%ghs8wu5+7n@)z944ax_m@oxt(%8yr6'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+    'django.template.loaders.filesystem.Loader',
+    'django.template.loaders.app_directories.Loader',
+#     'django.template.loaders.eggs.Loader',
+)
+
+MIDDLEWARE_CLASSES = (
+    'django.middleware.common.CommonMiddleware',
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'debug_toolbar.middleware.DebugToolbarMiddleware',
+)
+
+ROOT_URLCONF = 'ohr.urls'
+
+# Python dotted path to the WSGI application used by Django's runserver.
+WSGI_APPLICATION = 'ohr.wsgi.application'
+
+TEMPLATE_DIRS = (
+    os.path.join(PROJECT_ROOT, 'templates'),
+)
+
+TEMPLATE_CONTEXT_PROCESSORS = (
+    'django.contrib.auth.context_processors.auth',
+    'django.core.context_processors.debug',
+    'django.core.context_processors.i18n',
+    'django.core.context_processors.media',
+    'django.core.context_processors.static',
+    'django.contrib.messages.context_processors.messages',
+    'django.core.context_processors.request',
+)
+
+INSTALLED_APPS = (
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.sites',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    'django.contrib.admin',
+    'debug_toolbar',
+    'south',
+)
+
+# A sample logging configuration. The only tangible logging
+# performed by this configuration is to send an email to
+# the site admins on every HTTP 500 error when DEBUG=False.
+# See http://docs.djangoproject.com/en/dev/topics/logging for
+# more details on how to customize your logging configuration.
+LOGGING = {
+    'version': 1,
+    'disable_existing_loggers': False,
+    'filters': {
+        'require_debug_false': {
+            '()': 'django.utils.log.RequireDebugFalse'
+        }
+    },
+    'handlers': {
+        'mail_admins': {
+            'level': 'ERROR',
+            'filters': ['require_debug_false'],
+            'class': 'django.utils.log.AdminEmailHandler'
+        }
+    },
+    'loggers': {
+        'django.request': {
+            'handlers': ['mail_admins'],
+            'level': 'ERROR',
+            'propagate': True,
+        },
+    }
+}
+
+EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+LOGIN_URL = 'auth_login'
+LOGIN_REDIRECT_URL = '/'
+from django.conf.urls import patterns, include, url
+from django.contrib import admin
+
+admin.autodiscover()
+
+urlpatterns = patterns('',
+    url(r'', include('gamedb.urls')),
+    url(r'^admin/', include(admin.site.urls)),
+)