Changeset 40:5dc972fa3af6


Ignore:
Timestamp:
22.12.2011 15:51:06 (6 years ago)
Author:
hagenbruch@phoibe.ub.rub.de
Branch:
default
Tags:
tip
Message:

Enabled mail sending for titles entered in the publication forms

Location:
django
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • django/repo/search/views.py

    r39 r40  
    1616from django.template import Context 
    1717from django.template import RequestContext 
     18from django.template.base import Template 
    1819from django.template.response import TemplateResponse 
    1920from django.template.loader import get_template 
     
    4344from lxml import etree 
    4445 
    45 from django.core.mail import send_mail 
     46from django.core.mail import send_mail, mail_admins 
    4647from django.template.loader import get_template 
    4748from django.template import Context 
     
    23732374            pass 
    23742375 
    2375 #        try: 
    2376 #            profile = simplejson.load(urllib.urlopen('https://bibliographie-test.ub.rub.de/export/profile?id=%s' % pnd)) 
    2377 # 
    2378 #            for items in profile: 
    2379 #                for fields in items: 
    2380 #                    tmp = {} 
    2381 #                    myperson.setdefault(pnd, {}).setdefault('img', fields.get('fields').get('image')) 
    2382 #                    myperson.setdefault(pnd, {}).setdefault('description', fields.get('fields').get('descr')) 
    2383 #                    if fields.get('fields').get('label') != None: 
    2384 #                        tmp.setdefault('url', fields.get('fields').get('label')) 
    2385 #                    if fields.get('fields').get('type') != None: 
    2386 #                        tmp.setdefault('type', TYPES.get(fields.get('fields').get('type'))) 
    2387 #                    if tmp.has_key('url'): 
    2388 #                        myperson.setdefault(pnd, {}).setdefault('urls', []).append(tmp) 
    2389 #        except: 
    2390 #            raise 
    2391             #        params = 'q=pndid:%s&facet=true&facet.field=genrel1&facet.field=fakultaet&facet.mincount=1&facet.tree=genrel1,genrel2&facet.tree=fakultaet,fach&facet.tree=zentraleeinheit,fach&facet.field=zentraleeinheit&wt=python&rows=0' % pnd 
    2392         #        result = _fetch_result(params) 
    2393         #        #logging.debug(result) 
    2394         #        genre_tree = result['facet_counts']['trees']['genrel1,genrel2'] 
    2395         #        fak_tree = result['facet_counts']['trees']['fakultaet,fach'] 
    2396         #        ze_tree = result['facet_counts']['trees']['zentraleeinheit,fach'] 
    2397         # 
    2398         #        genre = result['facet_counts']['facet_fields']['genrel1'] 
    2399         #        fak = result['facet_counts']['facet_fields']['fakultaet'] 
    2400         #        ze = result['facet_counts']['facet_fields']['zentraleeinheit'] 
    2401         # 
    2402         #        fakultaet_facet = _concatenate_facets(fak, fak_tree) 
    2403         #        genre_facet = _concatenate_facets(genre, genre_tree) 
    2404         #        zentraleeinheit_facet = _concatenate_facets(ze, ze_tree) 
    2405         # 
    2406         #        params = 'q=pndid:%s&rows=5&facet=true&facet.field=fdate&facet.sort=index&wt=python&facet.mincount=1&fl=title+fdate+id&sort=fdate+desc' % pnd 
    2407         #        tresult = _fetch_result(params) 
    2408         #timeline = _make_timeline(tresult) 
    2409  
    24102376        profile = None 
    24112377        try: 
    24122378            profile = UserProfile.objects.get(pid=pnd) 
    2413 #            myperson.setdefault(pnd, {}).setdefault('email', profile.email) 
    2414 #            myperson.setdefault(pnd, {}).setdefault('img', profile.image) 
    2415 #            for myurl in profile.url_set.all(): 
    2416 #                tmp = {} 
    2417 #                tmp.setdefault('url', myurl.label) 
    2418 #                tmp.setdefault('type', TYPES.get(myurl.type)) 
    2419 #                myperson.setdefault(pnd, {}).setdefault('urls', []).append(tmp) 
    2420 #            for myaward in profile.award_set.all().order_by('-start'): 
    2421 #                tmp = {} 
    2422 #                tmp.setdefault('start', myaward.start) 
    2423 #                tmp.setdefault('end', myaward.end) 
    2424 #                tmp.setdefault('label', myaward.label) 
    2425 #                myperson.setdefault(pnd, {}).setdefault('awards', []).append(tmp) 
    2426  
    24272379        except UserProfile.DoesNotExist: 
    24282380            pass 
     
    37693721    for recipient in data.get('recipients'): 
    37703722        recipients.append(recipient.email) 
     3723    mail_admins(subject, message) 
    37713724    send_mail(subject, message, from_email, recipients) 
    37723725 
     
    42684221        mail_dict.setdefault('kid', record.kid) 
    42694222 
    4270     #_mail(mail_dict) 
     4223    _mail(mail_dict) 
    42714224    return HttpResponse(etree.tostring(mods, pretty_print=True), content_type='application/xml') 
    42724225 
  • django/repo/settings.py

    r39 r40  
    1111ADMINS = ( 
    1212          ('Andre Hagenbruch', 'andre.hagenbruch@rub.de'), 
     13          ('Veronika Josenhans', 'veronika.josenhans@rub.de'), 
     14          ('Hochschulbibliographie', 'bibliographie-ub@rub.de'), 
    1315          ) 
    1416 
  • django/templates/rd.html

    r38 r40  
    77    <script type="text/javascript" src="{{ STATIC_URL }}js/zingchart-html5beta-min.js"></script> 
    88{% endblock %} 
    9 {% block doctype %} id="fakultaet"{% endblock doctype %} 
    10 {% block breadcrumbs %}<a href="/" title="{% trans 'Home' %}">{% trans 'Campus Research Bibliography' %}</a> &#187; <a href="/faculties" title="{% trans 'Faculties' %}">{% trans 'Faculties' %}</a> &#187; <strong>{{ label }}</strong>{% endblock %} 
     9{% block doctype %} id="research_department"{% endblock doctype %} 
     10{% block breadcrumbs %}<a href="/" title="{% trans 'Home' %}">{% trans 'Campus Research Bibliography' %}</a> &#187; <a href="/research_campus" title="{% trans 'Research Departments' %}">{% trans 'Research Departments' %}</a> &#187; <strong>{{ label }}</strong>{% endblock %} 
    1111{% block content %} 
    1212<div id="col1"> 
    1313    <div id="col1_content" class="clearfix"> 
    1414        <h3>{{ label }}</h3> 
    15         {# {{ results }} #} 
    16         {# {{ departments_facet }} #} 
    17         {# {{ chairs_facet }} #} 
    18         {% if departments_facet %} 
    19             <h4>{% trans 'Browse by Department' %}</h4> 
     15        {% if faculties %} 
     16            <h4>{% trans 'Browse by Faculty' %}</h4> 
    2017            <ul> 
    21                 {% for fach in departments_facet %} 
    22                     {% for label, hits in fach.items %} 
    23                         <li class="department-icon"><a href="/department/{{ label|urlencode }}" title="{% trans "The department's profile page" %}"><strong>{{ label }}</strong></a> | <a href="/search?q=fach:%22{{ label|urlencode }}%22" title="{% blocktrans with label as unit %}Browse the {{ unit }} collection{% endblocktrans %}">{% blocktrans count counter=hits%}Browse their {{ counter }} title{% plural %}Browse their {{ counter }} titles{% endblocktrans %}</a></li> 
    24                     {% endfor %} 
    25                 {% endfor %} 
    26             </ul> 
    27             {% else %} 
    28             <h4>{% trans 'Browse by Chair' %}</h4> 
    29             <ul> 
    30                 {% for institut in chairs_facet %} 
    31                     {% for label, hits in institut.items %} 
    32                         <li class="chair-icon"><a href="/chair/{{ label|urlencode }}" title="{% trans "The chair's profile page" %}"><strong>{{ label }}</strong></a> | <a href="/search?q=institut:%22{{ label|urlencode }}%22" title="{% blocktrans with label as unit %}Browse the {{ unit }} collection{% endblocktrans %}">{% blocktrans count counter=hits%}Browse their {{ counter }} title{% plural %}Browse their {{ counter }} titles{% endblocktrans %}</a></li> 
     18                {% for faculty  in faculties %} 
     19                    {% for label, hits in faculty.items %} 
     20                        <li class="faculty-icon"><a href="/faculty/{{ label|urlencode }}" title="{% trans "The faculty's profile page" %}"><strong>{{ label }}</strong></a> | <a href="/search?q=fakultaet:%22{{ label|urlencode }}%22" title="{% blocktrans with label as unit %}Browse the {{ unit }} collection{% endblocktrans %}">{% blocktrans count counter=hits%}Browse their {{ counter }} title{% plural %}Browse their {{ counter }} titles{% endblocktrans %}</a></li> 
    3321                    {% endfor %} 
    3422                {% endfor %} 
     
    4129                        <li><a href="/entry/{{ doc.id }}" title="{{ doc.title }}">{% if doc.rubauthor %}{{ doc.rubauthor.0 }}: {% else %}{{ doc.institution.0 }}: {% endif %}{{ doc.title }} ({{ doc.fdate|unlocalize }})</a> </li> 
    4230                    {% endfor %} 
    43                     <li><a href="/search?q=fakultaet:%22{{ label }}%22&sort=fdate desc, title asc" class="mehr">{% trans 'All Recent Additions' %}</a></li> 
     31                    <li><a href="/search?q=institut:%22{{ label }}%22&sort=fdate desc, title asc" class="mehr">{% trans 'All Recent Additions' %}</a></li> 
    4432                </ul> 
    4533            </div> 
     
    5644<div id="col3"> 
    5745    <div id="col3_content" class="clearfix"> 
    58         {% with label as faculty %} 
     46        {% with label as research_department %} 
    5947        <h3>{% trans 'Most Frequent...' %}</h3> 
    6048        <h4>{% trans 'Series/Journal Titles' %}</h4> 
     
    6250            {% for journal in journals %} 
    6351                {% for label, hits in journal.items %} 
    64                     <li><a href="/search/?q=fakultaet:%22{{ faculty|urlencode }}%22&fq=fjtitle:%22{{ label|urlencode }}%22" title="{% trans 'Browse all Items of this Faculty in this Series or Journal' %}">{{ label }} ({{ hits }})</a></li> 
     52                    <li><a href="/search/?q=institut:%22{{ research_department|urlencode }}%22&fq=fjtitle:%22{{ label|urlencode }}%22" title="{% trans 'Browse all Items of this Research Department in this Series or Journal' %}">{{ label }} ({{ hits }})</a></li> 
    6553                {% endfor %} 
    6654            {% endfor %} 
     
    7058            {% for genre in genres %} 
    7159                {% for label, hits in genre.items %} 
    72                     <li><a href="/search?q=fakultaet:%22{{ faculty|urlencode }}%22&fq=genrel2:%22{{ label|urlencode }}%22" title="{% trans 'Browse all Items of this Faculty by this Publication Type' %}">{{ label }} ({{ hits }})</a></li> 
     60                    <li><a href="/search?q=institut:%22{{ research_department|urlencode }}%22&fq=genrel2:%22{{ label|urlencode }}%22" title="{% trans 'Browse all Items of this Research Department by this Publication Type' %}">{{ label }} ({{ hits }})</a></li> 
    7361                {% endfor %} 
    7462            {% endfor %} 
     
    8068</div> <!-- Ende  col3--> 
    8169    <script type="text/javascript"> 
    82         {% with label as faculty %} 
    83         var jsonConfig = '{"graphset":[{"type":"bar", "plot":{"tooltip-text": "%k:%v", "url": "/search?q=fakultaet:%22{{ faculty|urlencode }}%22&fq=fdate:%k"}, "scale-x":{"values": [{% for year in years %}{% for label, hits in year.items %}{{ label }}, {% endfor %}{% endfor %}]}, "series":[{"values":[{% for year in years %}{% for label, hits in year.items %}{{ hits|unlocalize }}, {% endfor %}{% endfor %}]}]}]}'; 
     70        {% with label as research_department %} 
     71        var jsonConfig = '{"graphset":[{"type":"bar", "plot":{"tooltip-text": "%k:%v", "url": "/search?q=institut:%22{{ research_department|urlencode }}%22&fq=fdate:%k"}, "scale-x":{"values": [{% for year in years %}{% for label, hits in year.items %}{{ label }}, {% endfor %}{% endfor %}]}, "series":[{"values":[{% for year in years %}{% for label, hits in year.items %}{{ hits|unlocalize }}, {% endfor %}{% endfor %}]}]}]}'; 
    8472        $(document).ready(function() { 
    8573            zingchart.render({ 
Note: See TracChangeset for help on using the changeset viewer.