app/soc/views/models/comment.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sun, 08 Mar 2009 13:14:28 +0000
changeset 1741 0da1285f5bc0
parent 1687 8203c805edc7
child 1769 7596a1d31723
permissions -rw-r--r--
Public reviews are now shown on the public page for the student proposal. The assigned mentor name has been removed from the public page. The student proposal view now uses the new getReviewsForEntity method. Patch by: Lennard de Rijk Reviewed by:to-be-reviewed
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
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    25
import time
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    26
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    27
from google.appengine.api import users
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    28
from google.appengine.ext.db import Key
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 django import forms
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    31
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    32
from soc.logic import cleaning
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    33
from soc.logic import dicts
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    34
from soc.logic import validate
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    35
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
    36
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
    37
from soc.logic.models.document import logic as document_logic
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    38
from soc.logic.models.linkable import logic as link_logic
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    39
from soc.models import linkable
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    40
from soc.views import helper
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    41
from soc.views.helper import access
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    42
from soc.views.helper import redirects
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    43
from soc.views.helper import params as params_helper
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    44
from soc.views.models import base
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    45
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    46
import soc.models.comment
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    47
import soc.logic.models.comment
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    48
import soc.logic.dicts
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    49
import soc.views.helper
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    50
import soc.views.helper.widgets
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
class View(base.View):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    54
  """View methods for the comment model.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    55
  """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    56
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    57
  def __init__(self, params=None):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    58
    """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
    59
    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
    60
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    61
    Params:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    62
      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
    63
      comment_on_name: e.g. 'Document'
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    64
      comment_on_url_name: e.g. 'document'
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    65
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    66
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    67
    rights = access.Checker(params)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    68
    rights['create'] = [('checkSeeded', ['checkIsDocumentReadable','scope_path'])]
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    69
    rights['edit'] = [('checkIsMyEntity', [comment_logic,'author', True])]
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    70
    rights['delete'] = [('checkIsMyEntity', [comment_logic,'author', True])]
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    71
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    72
    new_params = {}
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    73
    new_params['logic'] = comment_logic
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    74
    new_params['rights'] = rights
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    75
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    76
    new_params['name'] = "Comment"
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    77
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    78
    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
    79
    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
    80
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    81
    new_params['no_show'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    82
    new_params['no_admin'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    83
    new_params['no_create_raw'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    84
    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
    85
    new_params['no_list_raw'] = True
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    86
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    87
    new_params['create_extra_dynaproperties'] = {
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    88
        '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
    89
                                             required=False),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    90
        'content': forms.fields.CharField(
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    91
            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
    92
        '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
    93
        }
1687
8203c805edc7 Removed commented property from comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1678
diff changeset
    94
    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
    95
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    96
    new_params['edit_extra_dynaproperties'] = {
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    97
        'link_id': forms.CharField(widget=forms.HiddenInput, required=True),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    98
        'created_by': forms.fields.CharField(widget=helper.widgets.ReadOnlyInput(),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
    99
                                             required=False),
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   100
        }
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   101
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   102
    params = dicts.merge(params, new_params)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   103
    super(View, self).__init__(params=params)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   104
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   105
  def _editContext(self, request, context):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   106
    """see base.View._editContext.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   107
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   108
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   109
    entity = context['entity']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   110
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   111
    if entity:
1687
8203c805edc7 Removed commented property from comment model.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 1678
diff changeset
   112
      on = entity.scope
1678
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   113
    else:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   114
      seed = context['seed']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   115
      on =  seed['commented']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   116
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   117
    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
   118
    redirect = redirects.getPublicRedirect(on, params)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   119
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   120
    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
   121
    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
   122
    context['work_link'] = redirect
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   123
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   124
  def _editPost(self, request, entity, fields, params=None):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   125
    """See base.View._editPost().
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   126
    """
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
    user = user_logic.getForCurrentAccount()
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   129
    scope_path = fields['scope_path']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   130
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   131
    if not entity:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   132
      fields['author'] = user
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   133
      fields['link_id'] = 't%i' % (time.time())
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   134
    else:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   135
      fields['author'] = entity.author
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   136
      fields['link_id'] = entity.link_id
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   137
      fields['modified_by'] = user
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
    fields['commented'] = self._getWorkByKeyName(scope_path).key()
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
    super(View, self)._editPost(request, entity, fields)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   142
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   143
  def _editGet(self, request, entity, form):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   144
    """See base.View._editGet().
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   145
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   146
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   147
    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
   148
    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
   149
    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
   150
    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
   151
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   152
    super(View, self)._editGet(request, entity, form)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   153
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   154
  def _getWorkByKeyName(self, keyname):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   155
    """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
   156
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   157
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   158
    logic = self._params['comment_on_logic']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   159
    return logic.getFromKeyName(keyname)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   160
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   161
  def _editSeed(self, request, seed):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   162
    """Checks if scope_path is seeded and puts it into to_user.
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   163
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   164
    For parameters see base._editSeed()
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
    scope_path = seed['scope_path']
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   168
    work = self._getWorkByKeyName(scope_path)
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   169
    seed['on'] = work.title
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   170
    seed['commented'] = work
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   171
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   172
  def getMenusForScope(self, entity, params):
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   173
    """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
   174
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   175
    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
   176
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   177
    Args:
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   178
      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
   179
      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
   180
    """
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   181
80411f57f31a Added comment support, but don't enable it
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff changeset
   182
    return []