add docstrings in a bunch of places

This commit is contained in:
Frédéric Péters 2013-03-16 18:46:34 +01:00
parent 5c290e9657
commit 5c9149641d
11 changed files with 34 additions and 1 deletions

View File

@ -19,5 +19,6 @@
import importlib
def create_app(app_id, app_name, kwargs):
'''Create an application object of the requested type'''
module = importlib.import_module('univcloud.apps.%s' % app_name)
return module.App(app_id, **kwargs)

View File

@ -16,8 +16,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Add App'''
from .base import BaseApp
class App(BaseApp):
'''Add App, used to add new apps to the portal'''
app_id = 'add-app'
template_name = 'apps/add.html'

View File

@ -16,6 +16,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Base class for Apps'''
from django.template.loader import render_to_string
class BaseApp(object):

View File

@ -16,7 +16,10 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Clock App'''
from .base import BaseApp
class App(BaseApp):
'''Clock App, used to display an analog clock'''
template_name = 'apps/clock.html'

View File

@ -16,9 +16,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Feed App'''
from .base import BaseApp
class App(BaseApp):
'''Feed App, used to display a RSS feed'''
app_id = 'feed-app'
template_name = 'apps/feed.html'
sizex = 2

View File

@ -16,6 +16,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Help App'''
from .base import BaseApp
class App(BaseApp):

View File

@ -16,9 +16,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Launcher App'''
from .base import BaseApp
class App(BaseApp):
'''Launcher App, used to open a website full page'''
template_name = 'apps/launcher.html'
sizex = 2
sizey = 1

View File

@ -16,8 +16,11 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Weather App'''
from .base import BaseApp
class App(BaseApp):
'''Weather App, used to display the current weather'''
app_id = 'weather-app'
template_name = 'apps/weather.html'

View File

@ -16,9 +16,12 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Welcome App'''
from .base import BaseApp
class App(BaseApp):
'''Welcome App, used to display an informational message to users'''
template_name = 'apps/welcome.html'
sizex = 2
sizey = 2

View File

@ -22,6 +22,10 @@ from django.contrib.auth.models import User
from django.db import models
class UserProfile(models.Model):
'''User Profile Model
Stores the portal layout configuration, as json, in the layout field
'''
user = models.OneToOneField(User)
layout = models.CharField(max_length=10000)

View File

@ -16,6 +16,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
'''Views for displaying and manipulating the homepage'''
import json
import random
@ -28,6 +30,7 @@ from profile.models import UserProfile
from . import apps
class Homepage(TemplateView):
'''Homepage View, displays a serie of apps'''
template_name = 'univcloud/homepage.html'
def get_context_data(self, **kwargs):
@ -61,6 +64,7 @@ homepage = login_required(Homepage.as_view())
class Add(RedirectView):
'''Add View, used to add a new application to the portal'''
def get_redirect_url(self, appid):
profile = self.request.user.get_profile()
layout = profile.get_layout()
@ -72,6 +76,7 @@ add = login_required(Add.as_view())
class Dragstop(RedirectView):
'''Drag stop View, used to register the new position of an app'''
def get_redirect_url(self):
profile = self.request.user.get_profile()
layout = profile.get_layout()
@ -90,6 +95,7 @@ dragstop = login_required(Dragstop.as_view())
class Remove(RedirectView):
'''Remove View, used to remove an app from the portal'''
def get_redirect_url(self, app_id):
profile = self.request.user.get_profile()
layout = profile.get_layout()
@ -101,8 +107,8 @@ class Remove(RedirectView):
remove = login_required(Remove.as_view())
class Color(RedirectView):
'''Color View, used to set a new background color'''
def get_redirect_url(self, app_id):
profile = self.request.user.get_profile()
layout = profile.get_layout()