Changeset 2:bc4b7b630f6a

Show
Ignore:
Timestamp:
11/23/09 16:07:45 (6 days ago)
Author:
reno
Branch:
default
Message:

fix notifications

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • .hgignore

    r1 r2  
    11 
     2syntax: regexp 
     3^downloads$ 
    24syntax: regexp 
    35^settings_local\.py$ 
     
    1214syntax: regexp 
    1315^src/comt\.egg-info$ 
     16syntax: regexp 
     17^parts$ 
     18syntax: regexp 
     19^\.installed\.cfg$ 
  • src/cm/templates/site/text_notifications.html

    r0 r2  
    7171</script> 
    7272 
    73 <h2>{% blocktrans %}Embed the text{% endblocktrans %}</h2> 
     73<h2>{% blocktrans %}Embed text{% endblocktrans %}</h2> 
     74{% blocktrans %}Copy this code into your site to display text with comments. Users will also be able to add comments from your site depending an anonymous users' roles.{% endblocktrans %} 
    7475(<a title="{% blocktrans %}Help{% endblocktrans %}" target="_blank" href="{% url help %}#embed">?</a>) 
    75 <br /> 
    76 {% blocktrans %}Copy this code into your site to display text with comments. Users will also be able to add comments from your site depending an anonymous users' roles.{% endblocktrans %} 
    7776<br/> 
    7877<br/> 
    79 <textarea rows="4" cols="80" readonly="true"> 
    80 <iframe frameborder="0" src="{{ SITE_URL }}{% url text-view-comments-frame text.key %}" style="height: 166px; width: 99.9%; position: relative; top: 0px;">  
    81 </iframe> 
     78<input style="width:100%;background-color:#DDDDDD;" value="{{ embed_code }}" type="text" readonly="true"></input> 
    8279</textarea> 
    8380{% if not anonymous_can_view_text %} 
    8481<br/> 
    8582{% url text-share text.key as text_users_link %}  
    86 <span style="color:#F00;">{% blocktrans %}Warning:{% endblocktrans %}</span>{% blocktrans %}You won't be able to successfully embed the text before you <a href='{{ text_users_link }}'>give anonymous users</a> a role allowing them to view the text{% endblocktrans %}</span> 
     83<span style="color:#F00;">{% blocktrans %}Warning:{% endblocktrans %}</span>{% blocktrans %}You won't successfully embed the text before you <a href='{{ text_users_link }}'>give anonymous users</a> a role allowing them to view the text{% endblocktrans %}</span> 
    8784{% endif %} 
    8885</form> 
  • src/cm/views/notifications.py

    r0 r2  
    1414from django.utils import feedgenerator 
    1515from django.utils.translation import ugettext as _ 
    16 from cm.security import user_has_perm # import here! 
    1716 
    1817import re 
     
    7372    user = request.user if request.user.is_authenticated() else None 
    7473 
    75     anonymous_can_view_text = False 
    76     anonymous_user_role = UserRole.objects.get(user=None, text=text) 
    77     if anonymous_user_role : 
    78             anonymous_can_view_text = user_has_perm(anonymous_user_role.user, 'can_view_text', text=text) 
     74    from cm.security import user_has_perm # import here! 
     75    anonymous_can_view_text = user_has_perm(None, 'can_view_text', text=text) 
    7976    own_check = Notification.objects.filter(text=text,type='own',user=user).count() 
    8077    all_check = Notification.objects.filter(text=text,type=None,user=user).count() 
     78     
     79     
     80    embed_code = '<iframe frameborder="0" src="%s%s" style="height: 166px; width: 99.9%%; position: relative; top: 0px;">'%(settings.SITE_URL, reverse('text-view-comments-frame', args=[text.key]))    
     81     
    8182    if request.method == 'POST': 
    8283        if 'activate' in request.POST: 
     
    99100                     'text' : text, 
    100101                     'all_check' : all_check, 
    101                      'anonymous_can_view_text' : anonymous_can_view_text 
     102                     'anonymous_can_view_text' : anonymous_can_view_text, 
     103                     'embed_code': embed_code 
    102104                     } 
    103105    return render_to_response('site/text_notifications.html', template_dict , context_instance=RequestContext(request))