Skip to content

Commit

Permalink
changing person profile to be targeted at all agents, copied over con…
Browse files Browse the repository at this point in the history
…tact method display from symsys/views.py
  • Loading branch information
mikhuang committed May 5, 2013
1 parent 1e695e0 commit 78b8785
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
Expand Up @@ -5,7 +5,7 @@
{% block title-section %}{% endblock %}

{% block content %}
<div class="person-profile container">
<div class="agent-profile container">
<div class="row">
{% if item.photo %}
{% ifagentcan 'view FileDocument.datafile' item.photo %}
Expand All @@ -17,9 +17,8 @@
<div class="col-span-9">
<h1 title="title">{% viewable_name item %}</h1>
<ul>
{% for contactmethod in item.contact_methods.all %}
<!-- TODO: Check for permission to view! -->
<li>{{ contactmethod }}</li>
{% for contact_method in contact_methods %}
<li>{{ contact_method }}</li>
{% endfor %}
</ul>
</div>
Expand Down
48 changes: 41 additions & 7 deletions deme_django/cms/views.py
Expand Up @@ -830,6 +830,47 @@ class AgentViewer(ItemViewer):
accepted_item_type = Agent
viewer_name = 'agent'

def item_show_html(self):
self.context['action_title'] = ''
self.require_ability('view ', self.item, wildcard_suffix=True)
# copied from symsys/views.py
contact_method_fields = []
contact_methods = self.permission_cache.filter_items('view ContactMethod.agent', self.item.contact_methods).filter(active=True)
for contact_method in contact_methods:
if issubclass(contact_method.actual_item_type(), EmailContactMethod):
contact_method = contact_method.downcast()
if self.permission_cache.agent_can('view EmailContactMethod.email', contact_method):
contact_method_fields.append(contact_method.email)
if issubclass(contact_method.actual_item_type(), WebsiteContactMethod):
contact_method = contact_method.downcast()
if self.permission_cache.agent_can('view WebsiteContactMethod.url', contact_method):
link = ("""<a href="%s">%s</a>""" % (contact_method.url, contact_method.url))
contact_method_fields.append(mark_safe(link))
if issubclass(contact_method.actual_item_type(), PhoneContactMethod):
contact_method = contact_method.downcast()
if self.permission_cache.agent_can('view PhoneContactMethod.phone', contact_method):
contact_method_fields.append(contact_method.phone)
if issubclass(contact_method.actual_item_type(), FaxContactMethod):
contact_method = contact_method.downcast()
if self.permission_cache.agent_can('view FaxContactMethod.fax', contact_method):
contact_method_fields.append('(Fax) ' + contact_method.fax)
if issubclass(contact_method.actual_item_type(), AIMContactMethod):
contact_method = contact_method.downcast()
if self.permission_cache.agent_can('view AIMContactMethod.screen_name', contact_method):
contact_method_fields.append('(AIM Screename) ' + contact_method.screen_name)
if issubclass(contact_method.actual_item_type(), AddressContactMethod):
contact_method = contact_method.downcast()
if self.permission_cache.agent_can('view AddressContactMethod.street1', contact_method):
if contact_method.street2:
address = (""" %s <br> %s <br>%s, %s %s %s """ % (contact_method.street1, contact_method.street2, contact_method.city, contact_method.state, contact_method.country, contact_method.zip))
else:
address = (""" %s <br>%s, %s %s %s """ % (contact_method.street1, contact_method.city, contact_method.state, contact_method.country, contact_method.zip))
contact_method_fields.append(mark_safe(address))

self.context['contact_methods'] = contact_method_fields

template = loader.get_template('agent/show.html')
return HttpResponse(template.render(self.context))

class AnonymousAgentViewer(AgentViewer):
accepted_item_type = AnonymousAgent
Expand Down Expand Up @@ -911,13 +952,6 @@ class PersonViewer(AgentViewer):
accepted_item_type = Person
viewer_name = 'person'

def item_show_html(self):
self.context['action_title'] = ''
self.require_ability('view ', self.item, wildcard_suffix=True)

template = loader.get_template('person/show.html')
return HttpResponse(template.render(self.context))


class ContactMethodViewer(ItemViewer):
accepted_item_type = ContactMethod
Expand Down
6 changes: 3 additions & 3 deletions deme_django/static/css/deme.css
Expand Up @@ -5338,7 +5338,7 @@ you can use the generic selector below, but it's slower:
.proposition-result .proposition_graph .mark100 .count {
display: block;
}
.person-profile .thumb {
.agent-profile .thumb {
margin-top: 20px;
height: 200px;
background-size: cover;
Expand All @@ -5348,10 +5348,10 @@ you can use the generic selector below, but it's slower:
border: 1px solid #eee;
display: block;
}
.person-profile .thumb img {
.agent-profile .thumb img {
display: none;
}
.person-profile .activity-inner h3 {
.agent-profile .activity-inner h3 {
display: none;
}
.HiddenMenu {
Expand Down
2 changes: 1 addition & 1 deletion deme_django/static/less/deme/profiles.less
@@ -1,4 +1,4 @@
.person-profile {
.agent-profile {
.thumb {
margin-top: 20px;
height: 200px;
Expand Down

0 comments on commit 78b8785

Please sign in to comment.