app/soc/views/models/comment.py
author Lennard de Rijk <ljvderijk@gmail.com>
Thu, 30 Jul 2009 09:53:22 +0200
changeset 2688 dfe0439a0711
parent 2076 1cd180cc56c9
permissions -rw-r--r--
Added list of Surveys to the Project's manage page. This list will show wether or not a Survey has been taken and will also feature links to (re)take a Survey and in the near future to see the actual SurveyRecord. Note that the take Survey link is working however Org Admins will receive an access denied message when following this link.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     2
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     4
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     8
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    10
#
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    16
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    17
"""Views for comments.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    18
"""
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    19
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    20
__authors__ = [
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    21
    '"Sverre Rabbelier" <sverre@rabbelier.nl>',
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    22
    '"Matthew Wilkes" <matthew@matthewwilkes.co.uk>',
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    23
  ]
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    24
2076
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
    25
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
import time
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
from django import forms
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    29
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    30
from soc.logic import dicts
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
from soc.logic.models.user import logic as user_logic
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
from soc.logic.models.comment import logic as comment_logic
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
from soc.views import helper
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
from soc.views.helper import access
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
from soc.views.helper import redirects
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    36
from soc.views.models import base
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    37
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
class View(base.View):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
  """View methods for the comment model.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
  """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
  def __init__(self, params=None):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
    """Defines the fields and methods required for the base View class
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
    to provide the user with list, public, create, edit and delete views.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
    Params:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
      params: a dict with params for this View
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
      comment_on_name: e.g. 'Document'
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
      comment_on_url_name: e.g. 'document'
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    51
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    52
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    53
    rights = access.Checker(params)
2076
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
    54
    rights['create'] = [('checkSeeded', ['checkIsDocumentReadable', 
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
    55
        'scope_path'])]
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
    56
    rights['edit'] = [('checkIsMyEntity', [comment_logic, 'author', True])]
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
    57
    rights['delete'] = [('checkIsMyEntity', [comment_logic, 'author', True])]
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    59
    new_params = {}
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    60
    new_params['logic'] = comment_logic
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
    new_params['rights'] = rights
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    63
    new_params['name'] = "Comment"
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
    new_params['create_template'] = 'soc/comment/edit.html'
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
    new_params['edit_template'] = 'soc/comment/edit.html'
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
    new_params['no_show'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
    new_params['no_admin'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
    new_params['no_create_raw'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
    new_params['no_create_with_key_fields'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
    new_params['no_list_raw'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
    new_params['create_extra_dynaproperties'] = {
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
        'on': forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
                                             required=False),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
        'content': forms.fields.CharField(
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
            widget=helper.widgets.TinyMCE(attrs={'rows':10, 'cols':40})),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    79
        'scope_path': forms.CharField(widget=forms.HiddenInput, required=True),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    80
        }
1687
8203c805edc7 Removed commented property from comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1678
diff changeset
    81
    new_params['extra_dynaexclude'] = ['author', 'link_id', 'modified_by']
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
    new_params['edit_extra_dynaproperties'] = {
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    84
        'link_id': forms.CharField(widget=forms.HiddenInput, required=True),
2076
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
    85
        'created_by': forms.fields.CharField(
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
    86
            widget=helper.widgets.ReadOnlyInput(), required=False),
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
        }
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    88
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    89
    params = dicts.merge(params, new_params)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
    super(View, self).__init__(params=params)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    91
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    92
  def _editContext(self, request, context):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    93
    """see base.View._editContext.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    94
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    95
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    96
    entity = context['entity']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    97
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    98
    if entity:
1687
8203c805edc7 Removed commented property from comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1678
diff changeset
    99
      on = entity.scope
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   100
    else:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   101
      seed = context['seed']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   102
      on =  seed['commented']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   103
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   104
    params = {'url_name': self._params['comment_on_url_name']}
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   105
    redirect = redirects.getPublicRedirect(on, params)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   106
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   107
    context['comment_on_url_name'] = self._params['comment_on_url_name']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   108
    context['comment_on_name'] = self._params['comment_on_name']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   109
    context['work_link'] = redirect
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   110
2076
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
   111
  def _editPost(self, request, entity, fields):
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   112
    """See base.View._editPost().
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   113
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   114
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   115
    user = user_logic.getForCurrentAccount()
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   116
    scope_path = fields['scope_path']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   117
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   118
    if not entity:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   119
      fields['author'] = user
2076
1cd180cc56c9 Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1890
diff changeset
   120
      fields['link_id'] = 't%i' % (int(time.time()*100))
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   121
    else:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   122
      fields['author'] = entity.author
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
      fields['link_id'] = entity.link_id
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   124
      fields['modified_by'] = user
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   125
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   126
    fields['commented'] = self._getWorkByKeyName(scope_path).key()
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   127
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   128
    super(View, self)._editPost(request, entity, fields)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   129
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   130
  def _editGet(self, request, entity, form):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   131
    """See base.View._editGet().
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   132
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   133
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   134
    form.fields['created_by'].initial = entity.author.name
1687
8203c805edc7 Removed commented property from comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1678
diff changeset
   135
    form.fields['on'].initial = entity.scope.name
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   136
    form.fields['link_id'].initial = entity.link_id
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   137
    form.fields['scope_path'].initial = entity.scope_path
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   138
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   139
    super(View, self)._editGet(request, entity, form)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   140
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   141
  def _getWorkByKeyName(self, keyname):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   142
    """Returns the work for the specified key name.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   143
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   144
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   145
    logic = self._params['comment_on_logic']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   146
    return logic.getFromKeyName(keyname)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   147
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   148
  def _editSeed(self, request, seed):
1769
7596a1d31723 Remove some copy/pasted docstring in soc.views.models.comment module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 1687
diff changeset
   149
    """See base._editSeed().
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   150
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   151
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   152
    scope_path = seed['scope_path']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   153
    work = self._getWorkByKeyName(scope_path)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   154
    seed['on'] = work.title
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   155
    seed['commented'] = work
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   156
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   157
  def getMenusForScope(self, entity, params):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   158
    """Returns the featured menu items for one specifc entity.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   159
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   160
    A link to the home page of the specified entity is also included.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   161
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   162
    Args:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   163
      entity: the entity for which the entry should be constructed
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   164
      params: a dict with params for this View.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   165
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   166
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   167
    return []