Ejemplo n.º 1
0
    def tmpl_admin_alert_plain_text(self, journal_name, ln, issue):
        """
        Default plain text message for email alert of journal updates.
        This will be used to pre-fill the content of the mail alert, that
        can be modified by the admin.

        Customize this function to return different default texts
        based on journal name and language,
        """
        current_publication = get_issue_number_display(issue, journal_name, ln)
        plain_text = u'''Dear Subscriber,

    The latest issue of %(journal_name)s, no. %(current_publication)s, has been released.
    You can access it at the following URL:
    %(CFG_SITE_URL)s/journal/%(journal_name)s/

    Best Wishes,
    %(journal_name)s team

    ----
Cher Abonné,

    Le nouveau numéro de %(journal_name)s, no. %(current_publication)s, vient de paraître.
    Vous pouvez y accéder à cette adresse :
    %(CFG_SITE_URL)s/journal/%(journal_name)s/?ln=fr

    Bonne lecture,
    L'équipe de %(journal_name)s
    ''' % {'journal_name': journal_name,
           'current_publication': current_publication,
           'CFG_SITE_URL': CFG_SITE_URL}
        return plain_text
Ejemplo n.º 2
0
    def tmpl_admin_alert_plain_text(self, journal_name, ln, issue):
        """
        Default plain text message for email alert of journal updates.
        This will be used to pre-fill the content of the mail alert, that
        can be modified by the admin.

        Customize this function to return different default texts
        based on journal name and language,
        """
        current_publication = get_issue_number_display(issue, journal_name, ln)
        plain_text = u'''Dear Subscriber,

    The latest issue of %(journal_name)s, no. %(current_publication)s, has been released.
    You can access it at the following URL:
    %(CFG_SITE_URL)s/journal/%(journal_name)s/

    Best Wishes,
    %(journal_name)s team

    ----
Cher Abonné,

    Le nouveau numéro de %(journal_name)s, no. %(current_publication)s, vient de paraître.
    Vous pouvez y accéder à cette adresse :
    %(CFG_SITE_URL)s/journal/%(journal_name)s/?ln=fr

    Bonne lecture,
    L'équipe de %(journal_name)s
    ''' % {
            'journal_name': journal_name,
            'current_publication': current_publication,
            'CFG_SITE_URL': CFG_SITE_URL
        }
        return plain_text
Ejemplo n.º 3
0
    def tmpl_admin_alert_subject(self, journal_name, ln, issue):
        """
        Default subject for email alert of journal updates.

        Customize this function to return different default texts
        based on journal name and language,
        """
        return "%s %s released" % (journal_name, \
                                   get_issue_number_display(issue,
                                                            journal_name,
                                                            ln))
Ejemplo n.º 4
0
    def tmpl_admin_alert_subject(self, journal_name, ln, issue):
        """
        Default subject for email alert of journal updates.

        Customize this function to return different default texts
        based on journal name and language,
        """
        return "%s %s released" % (journal_name, \
                                   get_issue_number_display(issue,
                                                            journal_name,
                                                            ln))
Ejemplo n.º 5
0
def perform_administrate(ln=CFG_SITE_LANG, journal_name=None,
                         as_editor=True):
    """
    Administration of a journal

    Show the current and next issues/publications, and display links
    to more specific administrative pages.

    Parameters:
        journal_name  -  the journal to be administrated
                  ln  -  language
        with_editor_rights  -  True if can edit configuration. Read-only mode otherwise
    """
    if journal_name is None:
        try:
            journal_name = guess_journal_name(ln)
        except InvenioWebJournalNoJournalOnServerError as e:
            return e.user_box()

    if not can_read_xml_config(journal_name):
        return '<span style="color:#f00">Configuration could not be read. Please check that %s/webjournal/%s/%s-config.xml exists and can be read by the server.</span><br/>' % (CFG_ETCDIR, journal_name, journal_name)

    current_issue = get_current_issue(ln, journal_name)
    current_publication = get_issue_number_display(current_issue,
                                                   journal_name,
                                                   ln)
    issue_list = get_grouped_issues(journal_name, current_issue)
    next_issue_number = get_next_journal_issues(issue_list[-1], journal_name, 1)

    return wjt.tmpl_admin_administrate(journal_name,
                                       current_issue,
                                       current_publication,
                                       issue_list,
                                       next_issue_number[0],
                                       ln,
                                       as_editor=as_editor)
Ejemplo n.º 6
0
def perform_administrate(ln=CFG_SITE_LANG, journal_name=None,
                         as_editor=True):
    """
    Administration of a journal

    Show the current and next issues/publications, and display links
    to more specific administrative pages.

    Parameters:
        journal_name  -  the journal to be administrated
                  ln  -  language
        with_editor_rights  -  True if can edit configuration. Read-only mode otherwise
    """
    if journal_name is None:
        try:
            journal_name = guess_journal_name(ln)
        except InvenioWebJournalNoJournalOnServerError as e:
            return e.user_box()

    if not can_read_xml_config(journal_name):
        return '<span style="color:#f00">Configuration could not be read. Please check that %s/webjournal/%s/%s-config.xml exists and can be read by the server.</span><br/>' % (CFG_ETCDIR, journal_name, journal_name)

    current_issue = get_current_issue(ln, journal_name)
    current_publication = get_issue_number_display(current_issue,
                                                   journal_name,
                                                   ln)
    issue_list = get_grouped_issues(journal_name, current_issue)
    next_issue_number = get_next_journal_issues(issue_list[-1], journal_name, 1)

    return wjt.tmpl_admin_administrate(journal_name,
                                       current_issue,
                                       current_publication,
                                       issue_list,
                                       next_issue_number[0],
                                       ln,
                                       as_editor=as_editor)
Ejemplo n.º 7
0
def format_element(bfo, display_date='yes', display_issue_number='yes',
           estimate_release_date='No', granularity='',
           group_issues_date='yes', display_month='long',
           display_week_day='long'):
    """
    Returns the string used for the issue number in the format:<br/>
    Issue No.<is1>-<is2>/<year> - <date>, <br/>
    e.g. Issue No.32-33/2007 – Tuesday 6 August 2007

    if <code>estimate_release_date</code> is set to <code>yes</code>,
    a 'theoretical' release date is shown instead of the release date:
    if issue if released on Friday, display next week date. Also if
    journal has not been released, display an approximative release
    date (based on history and config)

    @param display_date: if 'yes', display issue date
    @param display_issue_number: if 'yes', display issue date
    @param estimate_release_date: if 'yes', display the theoretical release date
    @param granularity: <code>day</code>, <code>week</code> or <code>month</code>
    @param group_issues_date: if 'yes' and issue are grouped, display first issue date of the group
    @param display_month: type of display for month: 'short' ('Jan', 'Feb', etc.) or 'long' ('January', 'February', etc.)
    @param display_week_day: Can display day of the week ('Monday', etc.). Parameter can be 'short' ('Mon', 'Tue' etc), 'long' ('Monday', 'Tuesday', etc.) or '' (no value displayed)
    """
    args = parse_url_string(bfo.user_info['uri'])
    journal_name = args["journal_name"]
    issue_number = args["issue"]
    ln = bfo.lang
    _ = gettext_set_language(ln)

    try:
        issue_display = get_issue_number_display(issue_number,
                                                 journal_name,
                                                 ln)
    except InvenioWebJournalJournalIdNotFoundDBError as e:
        return e.user_box()
    except Exception as e:
        issue_display = issue_number

    issues = issue_display.split("/")[0]
    year = issue_display.split("/")[1]
    week_numbers = issues.split("-")

    if group_issues_date.lower() == 'yes':
        # Get release time of this issue (do not consider issue
        # "updates": take the earliest issue number of this group of
        # issues)
        grouped_issues = get_grouped_issues(journal_name, issue_number)
        if grouped_issues:
            issue_number = grouped_issues[0]

    if estimate_release_date.lower() == 'yes':
        # Get theoretical release date
        if granularity.lower() == 'day':
            granularity = DAILY
        elif granularity.lower() == 'week':
            granularity = WEEKLY
        elif granularity.lower() == 'month':
            granularity = MONTHLY
        else:
            granularity = None
        issue_release_time = issue_to_datetime(issue_number,
                                               journal_name,
                                               granularity)
    else:
        issue_release_time = get_release_datetime(issue_number,
                                                  journal_name)

    # Get a nice internationalized representation of this date
    date_text = ''
    if issue_release_time:
        if display_week_day:
            date_text = get_i18n_day_name(issue_release_time.isoweekday(),
                                          display_week_day,
                                          ln) + ' '
        month = get_i18n_month_name(issue_release_time.month,
                                    display_month,
                                    ln=ln)
        date_text += issue_release_time.strftime("%d " + month + " %Y").lstrip('0')

    issue_url = make_journal_url(bfo.user_info['uri'],
                                 {'recid': '',
                                  'ln': bfo.lang,
                                  'category': ''})
    out = '<a class="issue" href="%s">' % issue_url
    if display_issue_number.lower() == 'yes':
        out += _("Issue No.") + ' ' + issue_display + ' - '

    if display_date.lower() == 'yes':
        out += date_text

    out += '</a>'

    return out
Ejemplo n.º 8
0
def format_element(bfo, display_date='yes', display_issue_number='yes',
           estimate_release_date='No', granularity='',
           group_issues_date='yes', display_month='long',
           display_week_day='long'):
    """
    Returns the string used for the issue number in the format:<br/>
    Issue No.<is1>-<is2>/<year> - <date>, <br/>
    e.g. Issue No.32-33/2007 – Tuesday 6 August 2007

    if <code>estimate_release_date</code> is set to <code>yes</code>,
    a 'theoretical' release date is shown instead of the release date:
    if issue if released on Friday, display next week date. Also if
    journal has not been released, display an approximative release
    date (based on history and config)

    @param display_date: if 'yes', display issue date
    @param display_issue_number: if 'yes', display issue date
    @param estimate_release_date: if 'yes', display the theoretical release date
    @param granularity: <code>day</code>, <code>week</code> or <code>month</code>
    @param group_issues_date: if 'yes' and issue are grouped, display first issue date of the group
    @param display_month: type of display for month: 'short' ('Jan', 'Feb', etc.) or 'long' ('January', 'February', etc.)
    @param display_week_day: Can display day of the week ('Monday', etc.). Parameter can be 'short' ('Mon', 'Tue' etc), 'long' ('Monday', 'Tuesday', etc.) or '' (no value displayed)
    """
    args = parse_url_string(bfo.user_info['uri'])
    journal_name = args["journal_name"]
    issue_number = args["issue"]
    ln = bfo.lang
    _ = gettext_set_language(ln)

    try:
        issue_display = get_issue_number_display(issue_number,
                                                 journal_name,
                                                 ln)
    except InvenioWebJournalJournalIdNotFoundDBError as e:
        return e.user_box()
    except Exception as e:
        issue_display = issue_number

    issues = issue_display.split("/")[0]
    year = issue_display.split("/")[1]
    week_numbers = issues.split("-")

    if group_issues_date.lower() == 'yes':
        # Get release time of this issue (do not consider issue
        # "updates": take the earliest issue number of this group of
        # issues)
        grouped_issues = get_grouped_issues(journal_name, issue_number)
        if grouped_issues:
            issue_number = grouped_issues[0]

    if estimate_release_date.lower() == 'yes':
        # Get theoretical release date
        if granularity.lower() == 'day':
            granularity = DAILY
        elif granularity.lower() == 'week':
            granularity = WEEKLY
        elif granularity.lower() == 'month':
            granularity = MONTHLY
        else:
            granularity = None
        issue_release_time = issue_to_datetime(issue_number,
                                               journal_name,
                                               granularity)
    else:
        issue_release_time = get_release_datetime(issue_number,
                                                  journal_name)

    # Get a nice internationalized representation of this date
    date_text = ''
    if issue_release_time:
        if display_week_day:
            date_text = get_i18n_day_name(issue_release_time.isoweekday(),
                                          display_week_day,
                                          ln) + ' '
        month = get_i18n_month_name(issue_release_time.month,
                                    display_month,
                                    ln=ln)
        date_text += issue_release_time.strftime("%d " + month + " %Y").lstrip('0')

    issue_url = make_journal_url(bfo.user_info['uri'],
                                 {'recid': '',
                                  'ln': bfo.lang,
                                  'category': ''})
    out = '<a class="issue" href="%s">' % issue_url
    if display_issue_number.lower() == 'yes':
        out += _("Issue No.") + ' ' + issue_display + ' - '

    if display_date.lower() == 'yes':
        out += date_text

    out += '</a>'

    return out