# HG changeset patch # User Sverre Rabbelier # Date 1227384643 0 # Node ID 1bf2beedda03122a609c49033c9844586269a2d3 # Parent 4db464032b25ad347d3092a77ab8df63b0076ad0 Made Request use the new link_id and scope_path This cleans a lot of weird user interface badness and demonstrates how Linkable can be used. diff -r 4db464032b25 -r 1bf2beedda03 app/soc/logic/models/request.py --- a/app/soc/logic/models/request.py Sat Nov 22 18:58:32 2008 +0000 +++ b/app/soc/logic/models/request.py Sat Nov 22 20:10:43 2008 +0000 @@ -42,21 +42,19 @@ """See base.Logic.getKeyNameValues. """ - return [entity.role, entity.to.link_id, entity.requester.link_id] + return [entity.role, entity.scope.link_id, entity.link_id] def getKeyValuesFromFields(self, fields): """See base.Logic.getKeyValuesFromFields. """ - # TODO: "program_ln" might be needed here, since some Groups, such as - # Organizations, are per-Program, per-Year - return [fields['role'], fields['group_ln'], fields['user_ln']] + return [fields['role'], fields['scope_path'], fields['link_id']] def getKeyFieldNames(self): """See base.Logic.getKeyFieldNames. """ - return ['role', 'group_ln', 'user_ln'] + return ['role', 'scope_path', 'link_id'] logic = Logic() diff -r 4db464032b25 -r 1bf2beedda03 app/soc/models/request.py --- a/app/soc/models/request.py Sat Nov 22 18:58:32 2008 +0000 +++ b/app/soc/models/request.py Sat Nov 22 20:10:43 2008 +0000 @@ -33,25 +33,14 @@ """A request is made to allow a person to create a new Role entity. """ - requester = db.ReferenceProperty(reference_class=soc.models.user.User, - required=True, collection_name="requests") - requester.help_text = ugettext_lazy( - 'This is the user who the request is made for') - role = db.StringProperty() role.help_text = ugettext_lazy( 'This should be the type of the role that is requested') - to = db.ReferenceProperty(reference_class=soc.models.group.Group, - required=True, collection_name="requests") - to.help_text = ugettext_lazy( - 'The group that the request should be made to ' - '(this group should have the authority to grant the request)') + group_accepted = db.BooleanProperty() + group_accepted.help_text = ugettext_lazy( + 'Field used to indicate whether a request has been accepted by the group') - accepted = db.BooleanProperty() - accepted.help_text = ugettext_lazy( - 'Field used to indicate whether a request has been accepted') - - declined = db.BooleanProperty() - declined.help_text = ugettext_lazy( - 'Field used to indicate that a request has been rejected by the user') + user_accepted = db.BooleanProperty() + user_accepted.help_text = ugettext_lazy( + 'Field used to indicate that a request has been accepted by the user') diff -r 4db464032b25 -r 1bf2beedda03 app/soc/templates/soc/request/list/heading.html --- a/app/soc/templates/soc/request/list/heading.html Sat Nov 22 18:58:32 2008 +0000 +++ b/app/soc/templates/soc/request/list/heading.html Sat Nov 22 20:10:43 2008 +0000 @@ -2,6 +2,6 @@ Requester Role To - Accepted - Declined + Group Accepted + User Accepted diff -r 4db464032b25 -r 1bf2beedda03 app/soc/templates/soc/request/list/row.html --- a/app/soc/templates/soc/request/list/row.html Sat Nov 22 18:58:32 2008 +0000 +++ b/app/soc/templates/soc/request/list/row.html Sat Nov 22 20:10:43 2008 +0000 @@ -1,11 +1,11 @@
{{ list.item.role }}
-
{{ list.item.to.link_id }}
-
{{ list.item.accepted }}
-
{{ list.item.declined }}
+
{{ list.item.scope_path }}
+
{{ list.item.group_accepted }}
+
{{ list.item.group_accepted }}
diff -r 4db464032b25 -r 1bf2beedda03 app/soc/templates/soc/request/public.html --- a/app/soc/templates/soc/request/public.html Sat Nov 22 18:58:32 2008 +0000 +++ b/app/soc/templates/soc/request/public.html Sat Nov 22 20:10:43 2008 +0000 @@ -22,10 +22,10 @@

{% readonly_field_as_table_row entity.fields.role.label entity.role %} - {% readonly_field_as_table_row entity.fields.requester.label entity.requester.link_id %} - {% readonly_field_as_table_row entity.fields.to.label entity.to.link_id %} - {% readonly_field_as_table_row entity.fields.accepted.label entity.accepted %} - {% readonly_field_as_table_row entity.fields.declined.label entity.declined %} + {% readonly_field_as_table_row entity.fields.link_id.label entity.link_id %} + {% readonly_field_as_table_row entity.fields.scope_path.label entity.scope_path %} + {% readonly_field_as_table_row entity.fields.user_accepted.label entity.group_accepted %} + {% readonly_field_as_table_row entity.fields.group_accepted.label entity.user_accepted %}

diff -r 4db464032b25 -r 1bf2beedda03 app/soc/views/models/request.py --- a/app/soc/views/models/request.py Sat Nov 22 18:58:32 2008 +0000 +++ b/app/soc/views/models/request.py Sat Nov 22 20:10:43 2008 +0000 @@ -54,18 +54,18 @@ model = soc.models.request.Request #: list of model fields which will *not* be gathered by the form - exclude = ['inheritance_line', 'requester', 'to', 'role', 'declined'] + exclude = ['inheritance_line', 'scope', 'scope_path', 'link_id', 'role', 'declined'] role = forms.CharField(widget=helper.widgets.ReadOnlyInput()) user = forms.CharField( - label=soc.models.request.Request.requester.verbose_name, - help_text=soc.models.request.Request.requester.help_text, - widget=helper.widgets.ReadOnlyInput()) + label=soc.models.request.Request.link_id.verbose_name, + help_text=soc.models.request.Request.link_id.help_text, + widget=helper.widgets.ReadOnlyInput()) group = forms.CharField( - label=soc.models.request.Request.to.verbose_name, - help_text=soc.models.request.Request.to.help_text, + label=soc.models.request.Request.scope.verbose_name, + help_text=soc.models.request.Request.scope.help_text, widget=helper.widgets.ReadOnlyInput()) def clean_user(self): @@ -147,8 +147,8 @@ # construct the Unhandled Requests list # only select the requests for this user that haven't been handled yet - filter = {'requester': user_entity, - 'declined' : None} + filter = {'link_id': user_entity.link_id, + 'group_accepted' : True} uh_params = params.copy() uh_params['list_action'] = (self.inviteAcceptedRedirect, None) @@ -161,8 +161,8 @@ # only select the requests for the user # that haven't been accepted by an admin yet - filter = {'requester' : user_entity, - 'accepted' : None} + filter = {'link_id' : user_entity.link_id, + 'group_accepted' : False} ar_params = params.copy() ar_params['list_description'] = ugettext_lazy( @@ -181,31 +181,32 @@ """ return '/%s/create/%s/%s' % ( - entity.role, entity.to.link_id, entity.requester.link_id) + entity.role, entity.scope_path, entity.link_id) def _editSeed(self, request, seed): """See base.View._editGet(). """ # fill in the email field with the data from the entity - seed['user'] = seed['user_ln'] - seed['group'] = seed['group_ln'] + seed['user'] = seed['link_id'] + seed['group'] = seed['scope_path'] def _editGet(self, request, entity, form): """See base.View._editGet(). """ # fill in the email field with the data from the entity - form.fields['user'].initial = entity.requester.link_id - form.fields['group'].initial = entity.to.link_id + form.fields['user'].initial = entity.link_id + form.fields['group'].initial = entity.scope_path def _editPost(self, request, entity, fields): """See base.View._editPost(). """ # fill in the account field with the user created from email - fields['user_ln'] = fields['requester'].link_id - fields['group_ln'] = fields['to'].link_id + fields['link_id'] = fields['requester'].link_id + fields['scope_path'] = fields['to'].link_id + fields['scope'] = fields['to'] view = View()