Пример #1
0
def show_story_short(story, no_number=False, markup=True):
    if no_number:
        story_line = u''
    else:
        story_line = u'%s.' % story.sequence_number

    if story.title or story.first_line:
        title = show_title(story, True)
    else:
        if markup:
            title = '<span class="no_data">no title</span>'
        else:
            title = 'no title'
    if story.feature:
        story_line = u'%s %s (%s)' % (esc(story_line), title,
                                      esc(story.feature))
    else:
        if markup:
            story_line = u'%s %s (%s)' % (
              esc(story_line),
              title,
              '<span class="no_data">no feature</span>')
        else:
            story_line = u'%s %s (no feature)' % (esc(story_line), title)

    story_line = u'%s %s' % (story_line, story.type)
    page_count = show_page_count(story)
    if page_count:
        story_line += ', %sp' % page_count
    else:
        if markup:
            story_line += '<span class="no_data"> no page count</span>'
        else:
            story_line += 'no page count'
    return mark_safe(story_line)
Пример #2
0
def follow_reprint_link(reprint, direction, level=0):
    if level > 10: # max level to avoid loops
        return ''
    reprint_note = ''
    text = False
    if direction == 'from':
        further_reprints = list(reprint.origin.from_reprints.select_related().all())
        further_reprints.extend(list(reprint.origin.from_issue_reprints.select_related().all()))
        further_reprints = sorted(further_reprints, key=lambda a: a.origin_sort)
        reprint_note += generate_reprint_notes(from_reprints=further_reprints,
                                               level=level)
        if reprint.origin.reprint_notes:
            for string in split_reprint_string(reprint.origin.reprint_notes):
                string = string.strip()
                if string.lower().startswith('from '):
                    text = True
                    reprint_note += '<li> ' + esc(string) + ' </li>'
    else:
        further_reprints = list(reprint.target.to_reprints.select_related().all())
        further_reprints.extend(list(reprint.target.to_issue_reprints.select_related().all()))
        further_reprints = sorted(further_reprints, key=lambda a: a.target_sort)
        reprint_note += generate_reprint_notes(to_reprints=further_reprints,
                                               level=level)
        if reprint.target.reprint_notes:
            for string in split_reprint_string(reprint.target.reprint_notes):
                string = string.strip()
                if string.lower().startswith('in '):
                    text = True
                    reprint_note += '<li> ' + esc(string) + ' </li>'

    if reprint_note != '':
        reprint_note = 'which is reprinted<ul>%s</ul>' % reprint_note
    return reprint_note
def __format_credit(story, credit):
    credit_value = getattr(story, credit)
    if not __credit_visible(credit_value):
        return ''

    if (credit == 'job_number'):
        label = _('Job Number:')
    else:
        label = _(credit.title()) + ':'

    if (credit == 'reprint_notes'):
        label = _('Reprinted:')
        values = split_reprint_string(credit_value)
        credit_value = '<ul>'
        for value in values:
            credit_value += '<li>' + esc(value)
        credit_value += '</ul>'
    else: # This takes care of escaping the database entries we display
        credit_value = esc(credit_value)
    dt = '<dt class="credit_tag'
    dd = '<dd class="credit_def'
    if credit == 'genre':
        dt += ' short' 
        dd += ' short'
    dt += '">'
    dd += '">'

    return mark_safe(
           dt + '<span class="credit_label">' + label + '</span></dt>' + \
           dd + '<span class="credit_value">' + credit_value + '</span></dd>')
def show_story_short(story, no_number=False):
    if no_number:
        story_line = u''
    else:
        story_line = u'%s.' % story.sequence_number

    if story.title:
        if story.title_inferred:
            title = u'[%s]' % esc(story.title)
        else:
            title = esc(story.title)
    else:
        title = '<span class="no_data">no title</span>'
    if story.feature:
        story_line = u'%s %s (%s)' % (esc(story_line), title,
                                      esc(story.feature))
    else:
        story_line = u'%s %s (%s)' % (esc(story_line), title,
                                     '<span class="no_data">no feature</span>')
    story_line = u'%s %s' % (story_line, story.type)
    page_count = show_page_count(story)
    if page_count:
        story_line += ', %sp' % page_count
    else:
        story_line += '<span class="no_data"> no page count</span>'

    return mark_safe(story_line)
def show_issue(issue):
    return mark_safe('<a href="%s">%s</a> (%s series) <a href="%s">#%s</a>' %
                     (issue.series.get_absolute_url(),
                      esc(issue.series.name),
                      esc(issue.series.year_began),
                      issue.get_absolute_url(),
                      esc(issue.display_number)))
Пример #6
0
def generate_reprint_link_sequence(story, from_to, notes=None, li=True,
                                   only_number=False):
    ''' generate reprint link to story'''
    if only_number:
        link = u', <a href="%s#%d">%s</a>' % (story.issue.get_absolute_url(),
                                              story.id,
                                              esc(story.issue.display_number))
    elif story.sequence_number == 0:
        link = u'%s %s <a href="%s#%d">%s</a>' % \
          (get_country_flag(story.issue.series.country), from_to,
           story.issue.get_absolute_url(), story.id,
           esc(story.issue.full_name()))
    else:
        link = u'%s %s <a href="%s#%d">%s</a>' % \
          (get_country_flag(story.issue.series.country), from_to,
           story.issue.get_absolute_url(), story.id,
           esc(story.issue.full_name(variant_name=False)))
    if story.issue.publication_date:
        link = "%s (%s)" % (link, esc(story.issue.publication_date))
    if notes:
        link = '%s [%s]' % (link, esc(notes))
    if li and not only_number:
        return '<li> ' + link
    else:
        return link
Пример #7
0
 def full_name_with_link(self):
     name_link = '<a href="%s">%s</a> ' % (self.award.get_absolute_url(),
                                           esc(self.award))
     name_link += '- <a href="%s">%s (%s)</a>' % (self.get_absolute_url(),
                                                  esc(self.display_name()),
                                                  esc(self.display_year()))
     return mark_safe(name_link)
 def render(self, context):
     return_string = ""
     for i in self.issues:
         return_string += "<a href=\"" + i.get_absolute_url() + "\">" + \
                          esc(i.series) + " #" + esc(i.number) + "</a> (" + \
                          esc(i.series.publisher.name) + ")<br/><br/>"
     return mark_safe(return_string)
def upload_cover(request, cover_id=None, issue_id=None):
    """
    Handles uploading of covers be it
    - first upload
    - replacement upload
    - variant upload
    """

    # this cannot actually happen
    if cover_id and issue_id:
        raise ValueError

    # if cover_id is present it is a replacement upload
    if cover_id:
        cover = get_object_or_404(Cover, id=cover_id)
        issue = cover.issue
    # no cover_id, therefore upload a cover to an issue (first or variant)
    else:
        issue = get_object_or_404(Issue, id=issue_id)
        if not issue.series.is_comics_publication:
            return render_error(request,
              'No covers for non-comics publications.', redirect=False)
        cover = None

    # check if there is a pending issue deletion
    if IssueRevision.objects.filter(issue=issue, deleted=True,
                                    changeset__state__in=states.ACTIVE):
        revision = IssueRevision.objects.get(issue=issue,
          changeset__state__in=states.ACTIVE)
        return render_error(request,
          ('%s is <a href="%s">pending deletion</a>. Covers '
          'cannot be added or modified.') % (esc(issue),
          urlresolvers.reverse('compare', kwargs={'id': revision.changeset.id})),
          redirect=False, is_safe=True)

    # check if there is a pending change for the cover
    if cover_id and CoverRevision.objects.filter(cover=cover,
                    changeset__state__in=states.ACTIVE):
        revision = CoverRevision.objects.get(cover=cover,
          changeset__state__in=states.ACTIVE)
        return render_error(request,
          ('There currently is a <a href="%s">pending replacement</a> '
          'for this cover of %s.') % (urlresolvers.reverse('compare',
          kwargs={'id': revision.changeset.id}), esc(cover.issue)),
          redirect=False, is_safe=True)

    # current request is an upload
    if request.method == 'POST':
        return handle_uploaded_cover(request, cover, issue)
    # request is a GET for the form
    else:
        if 'oi_file_source' in request.session:
            vars = {'source' : request.session['oi_file_source'],
                    'remember_source' : True}
        else:
            vars = None
        form = UploadScanForm(initial=vars)

        # display the form
        return _display_cover_upload_form(request, form, cover, issue)
Пример #10
0
def menuitem(context, url, title):
    request = context['request']
    class_attr = ''
    if request.path == url:
        class_attr = ' class="active"'
    template =  u'<li{class_attr}><a href="{url}">{title}</a></li>'
    return mark_safe(template.format(url=esc(url), title=esc(title), class_attr=class_attr))
Пример #11
0
def project_div(project):
    d = dict(name=esc(project.name), color=esc(project.color))
    if project.display_as_free:
        return mark_safe('<div class="project %(color)s"></div>' % d)
    else:
        d['url'] = project.get_absolute_url()
        return mark_safe('<a href="%(url)s" class="project %(color)s" title="%(name)s"></a>' % d)
Пример #12
0
def project_members(people):
    html = ['<ul class="unstyled project-members">']
    for person in people:
        d = {'url': esc(person.get_absolute_url()), 'color': esc(person.color),
             'name': esc(person.name)}
        html.append(MEMBER_TAG % d)
    html.append('</ul>')
    return mark_safe('\n'.join(html))
def login(request, template_name):
    """
    Do some pre-checking before handing off to the standard login view.
    If anything goes wrong just let the standard login handle it.
    """

    if request.user.is_authenticated():
        return HttpResponseRedirect(urlresolvers.reverse("default_profile"))

    try:
        if request.method == "POST":
            try:
                user = User.objects.get(email=request.POST["username"])
            except (User.DoesNotExist, User.MultipleObjectsReturned):
                user = User.objects.get(username=request.POST["username"])

            if user.indexer.registration_expires is not None:
                if date.today() > (user.indexer.registration_expires + timedelta(1)):
                    return render_error(
                        request,
                        (
                            'The account with the email "%s" was never confirmed '
                            'and has expired.  You may <a href="'
                            + urlresolvers.reverse("register")
                            + '">re-register</a>.  '
                        )
                        % esc(user.email),
                        is_safe=True,
                    )
                return render_error(
                    request,
                    (
                        'The account with email "%s" has not yet been confirmed. '
                        "You should receive an email that gives you a URL to visit "
                        "to confirm your account.  After you have visited that URL "
                        "you will be able to log in and use your account.  Please "
                        '<a href="mailto:%s">contact us</a> if you do not receive '
                        "the email within a few hours."
                    )
                    % (esc(user.email), settings.EMAIL_CONTACT),
                    is_safe=True,
                )

    except User.DoesNotExist:
        pass

    if "next" in request.POST:
        next = request.POST["next"]
        if re.match(r"/accounts/confirm/", next, flags=re.I):
            post = request.POST.copy()
            post["next"] = urlresolvers.reverse("welcome")
            request.POST = post
        if re.match(r"/gcd-error/", next, flags=re.I):
            post = request.POST.copy()
            post["next"] = urlresolvers.reverse("home")
            request.POST = post

    return standard_login(request, template_name=template_name, authentication_form=LongUsernameAuthenticationForm)
Пример #14
0
def upload_cover(request, cover_id=None, issue_id=None):
    """
    Handles uploading of covers be it
    - first upload
    - replacement upload
    - variant upload
    """

    # this cannot actually happen
    if cover_id and issue_id:
        raise ValueError

    # if cover_id is present it is a replacement upload
    if cover_id:
        cover = get_object_or_404(Cover, id=cover_id)
        issue = cover.issue
    # no cover_id, therefore upload a cover to an issue (first or variant)
    else:
        issue = get_object_or_404(Issue, id=issue_id)
        cover = None

    # check if there is a pending issue deletion
    if IssueRevision.objects.filter(issue=issue, deleted=True,
                                    changeset__state__in=states.ACTIVE):
        revision = IssueRevision.objects.get(issue=issue,
          changeset__state__in=states.ACTIVE)
        return render_error(request,
          ('%s is <a href="%s">pending deletion</a>. Covers '
          'cannot be added or modified.') % (esc(issue),
          urlresolvers.reverse('compare', kwargs={'id': revision.changeset.id})),
          redirect=False, is_safe=True)

    # check if there is a pending change for the cover
    if cover_id and CoverRevision.objects.filter(cover=cover,
                    changeset__state__in=states.ACTIVE):
        revision = CoverRevision.objects.get(cover=cover,
          changeset__state__in=states.ACTIVE)
        return render_error(request,
          ('There currently is a <a href="%s">pending replacement</a> '
          'for this cover of %s.') % (urlresolvers.reverse('compare',
          kwargs={'id': revision.changeset.id}), esc(cover.issue)),
          redirect=False, is_safe=True)

    # current request is an upload
    if request.method == 'POST':
        return handle_uploaded_cover(request, cover, issue)
    # request is a GET for the form
    else:
        if 'oi_file_source' in request.session:
            vars = {'source' : request.session['oi_file_source'],
                    'remember_source' : True}
        else:
            vars = None
        form = UploadScanForm(initial=vars)

        # display the form
        return _display_cover_upload_form(request, form, cover, issue)
Пример #15
0
def absolute_url(item, additional=''):
    if item is not None and hasattr(item, 'get_absolute_url'):
        if additional:
            return mark_safe(u'<a href="%s" %s>%s</a>' %
                             (item.get_absolute_url(), additional, esc(item)))
        else:
            return mark_safe(u'<a href="%s">%s</a>' %
                             (item.get_absolute_url(), esc(item)))
    return ''
Пример #16
0
def show_reprints(story, original=False):
    """ Filter for our reprint line on the story level."""

    reprint = ""

    from_reprints = list(story.from_reprints.select_related().all())
    from_reprints.extend(list(
        story.from_issue_reprints.select_related().all()))
    from_reprints = sorted(from_reprints, key=lambda a: a.origin_sort)
    reprint = generate_reprint_notes(from_reprints=from_reprints,
                                     original=original)

    if story.type.id != STORY_TYPES['promo']:
        no_promo = True
    else:
        no_promo = False
    to_reprints = list(story.to_reprints.select_related().all())
    to_reprints.extend(list(story.to_issue_reprints.select_related().all()))
    to_reprints = sorted(to_reprints, key=lambda a: a.target_sort)
    reprint += generate_reprint_notes(to_reprints=to_reprints,
                                      original=original,
                                      no_promo=no_promo)

    if story.reprint_notes:
        for string in split_reprint_string(story.reprint_notes):
            string = string.strip()
            reprint += '<li> ' + esc(string) + ' </li>'

    if reprint != '' or (original and not story.reprint_confirmed and \
                         story.migration_status.reprint_original_notes):
        label = _('Reprints') + ': '
        if original:
            if not story.reprint_confirmed and \
              story.migration_status.reprint_original_notes:
                reprint += '</ul></span></dd>' + \
                  '<dt class="credit_tag">' + '<span class="credit_label">' + \
                  'Reprint Note before Migration: </span></dt>' + \
                  '<dd class="credit_def"><span class="credit_value"><ul>'
                for string in split_reprint_string(
                        story.migration_status.reprint_original_notes):
                    string = string.strip()
                    reprint += '<li> ' + esc(string) + ' </li>'
        else:
            if not story.reprint_confirmed:
                label += '<span class="linkify">' + \
                        '<a href="?original_reprint_notes=True">' + \
                        'show reprint note before migration</a></span>'
            if story.reprint_needs_inspection:
                label += ' (migrated reprint links need inspection)'

        return mark_safe('<dt class="credit_tag">' + \
                         '<span class="credit_label">' + label + '</span></dt>' + \
                         '<dd class="credit_def">' + \
                         '<span class="credit_value">' + \
                         '<ul>' + reprint + '</ul></span></dd>')
    else:
        return ""
def absolute_url(item, additional=''):
    if item is not None and hasattr(item, 'get_absolute_url'):
        if additional:
            return mark_safe(u'<a href="%s" %s>%s</a>' %
                             (item.get_absolute_url(), additional, esc(item)))
        else:
            return mark_safe(u'<a href="%s">%s</a>' %
                             (item.get_absolute_url(), esc(item)))
    return ''
Пример #18
0
def show_reprints(story, original=False):
    """ Filter for our reprint line on the story level."""

    reprint = ""

    from_reprints = list(story.from_reprints.select_related().all())
    from_reprints.extend(list(story.from_issue_reprints.select_related()
                                                       .all()))
    from_reprints = sorted(from_reprints, key=lambda a: a.origin_sort)
    reprint = generate_reprint_notes(from_reprints=from_reprints,
                                     original=original)

    if story.type.id != STORY_TYPES['promo']:
        no_promo = True
    else:
        no_promo = False
    to_reprints = list(story.to_reprints.select_related().all())
    to_reprints.extend(list(story.to_issue_reprints.select_related().all()))
    to_reprints = sorted(to_reprints, key=lambda a: a.target_sort)
    reprint += generate_reprint_notes(to_reprints=to_reprints,
                                      original=original, no_promo=no_promo)

    if story.reprint_notes:
        for string in split_reprint_string(story.reprint_notes):
            string = string.strip()
            reprint += '<li> ' + esc(string) + ' </li>'

    if reprint != '' or (original and not story.reprint_confirmed and
                         story.migration_status.reprint_original_notes):
        label = _('Reprints') + ': '
        if original:
            if not story.reprint_confirmed and \
              story.migration_status.reprint_original_notes:
                reprint += '</ul></span></dd>' + \
                  '<dt class="credit_tag">' + '<span class="credit_label">' + \
                  'Reprint Note before Migration: </span></dt>' + \
                  '<dd class="credit_def"><span class="credit_value"><ul>'
                for string in split_reprint_string(story.migration_status.
                                                   reprint_original_notes):
                    string = string.strip()
                    reprint += '<li> ' + esc(string) + ' </li>'
        else:
            if not story.reprint_confirmed:
                label += '<span class="linkify">' + \
                        '<a href="?original_reprint_notes=True">' + \
                        'show reprint note before migration</a></span>'
            if story.reprint_needs_inspection:
                label += ' (migrated reprint links need inspection)'

        return mark_safe('<dt class="credit_tag">' +
                         '<span class="credit_label">' + label +
                         '</span></dt>' + '<dd class="credit_def">' +
                         '<span class="credit_value">' +
                         '<ul>' + reprint + '</ul></span></dd>')
    else:
        return ""
Пример #19
0
def upload_image(request, model_name, id, image_type, image=None):
    from apps.oi.views import DISPLAY_CLASSES, REVISION_CLASSES
    """
    Handles uploading of supporting images
    """

    display_obj = get_object_or_404(DISPLAY_CLASSES[model_name], id=id,
                                    deleted=False)

    kwargs = None
    # replacement
    if image:
        if image.object != display_obj:
            return render_error(request,
              'Image and object id do not match.',
              redirect=False, is_safe=True)
        kwargs = {'upload_type': 'replacement', 'current_image': image,
          'current_image_tag': get_generic_image_tag(image, 'current image')}
    # check if there is an image if image_type.unique is set
    else:
        img_type = get_object_or_404(ImageType, name=image_type)
        if img_type.unique:
            if Image.objects.filter(content_type=\
              ContentType.objects.get_for_model(display_obj),
              object_id=display_obj.id, type=img_type, deleted=False).count():
                return render_error(request,
                  ('%s has an image. Further images cannot be added, '
                  'only replaced.') % (esc(display_obj)),
                  redirect=False, is_safe=True)

    # check if there is a pending object deletion
    filter_dict = {model_name : display_obj, 'deleted' : True,
                   'changeset__state__in' : states.ACTIVE}
    revision = REVISION_CLASSES[model_name].objects.filter(**filter_dict)
    if revision:
        revision = revision.get()
        return render_error(request,
          ('%s is <a href="%s">pending deletion</a>. Images '
          'cannot be added or modified.') % (esc(display_obj),
          urlresolvers.reverse('compare', kwargs={'id': revision.changeset.id})),
          redirect=False, is_safe=True)

    # current request is an upload
    if request.method == 'POST':
        if image:
            return handle_uploaded_image(request, display_obj, model_name,
                                         image_type, current_image=image)
        else:
            return handle_uploaded_image(request, display_obj, model_name,
                                         image_type)
    # request is a GET for the form
    else:
        form = UploadImageForm()
        # display the form
        return _display_image_upload_form(request, form, display_obj,
                                          model_name, image_type, kwargs=kwargs)
def upload_image(request, model_name, id, image_type, image=None):
    from apps.oi.views import DISPLAY_CLASSES, REVISION_CLASSES
    """
    Handles uploading of supporting images
    """

    display_obj = get_object_or_404(DISPLAY_CLASSES[model_name], id=id,
                                    deleted=False)

    kwargs = None
    # replacement
    if image:
        if image.object != display_obj:
            return render_error(request,
              'Image and object id do not match.',
              redirect=False, is_safe=True)
        kwargs = {'upload_type': 'replacement', 'current_image': image,
          'current_image_tag': get_generic_image_tag(image, 'current image')}
    # check if there is an image if image_type.unique is set
    else:
        img_type = get_object_or_404(ImageType, name=image_type)
        if img_type.unique:
            if Image.objects.filter(content_type=\
              ContentType.objects.get_for_model(display_obj),
              object_id=display_obj.id, type=img_type, deleted=False).count():
                return render_error(request,
                  ('%s has an image. Further images cannot be added, '
                  'only replaced.') % (esc(display_obj)),
                  redirect=False, is_safe=True)

    # check if there is a pending object deletion
    filter_dict = {model_name : display_obj, 'deleted' : True,
                   'changeset__state__in' : states.ACTIVE}
    revision = REVISION_CLASSES[model_name].objects.filter(**filter_dict)
    if revision:
        revision = revision.get()
        return render_error(request,
          ('%s is <a href="%s">pending deletion</a>. Images '
          'cannot be added or modified.') % (esc(display_obj),
          urlresolvers.reverse('compare', kwargs={'id': revision.changeset.id})),
          redirect=False, is_safe=True)

    # current request is an upload
    if request.method == 'POST':
        if image:
            return handle_uploaded_image(request, display_obj, model_name,
                                         image_type, current_image=image)
        else:
            return handle_uploaded_image(request, display_obj, model_name,
                                         image_type)
    # request is a GET for the form
    else:
        form = UploadImageForm()
        # display the form
        return _display_image_upload_form(request, form, display_obj,
                                          model_name, image_type, kwargs=kwargs)
def get_preview_image_tag(revision, alt_text, zoom_level):
    if revision is None:
        return mark_safe('<img class="no_cover" src="' + settings.MEDIA_URL + \
               'img/nocover.gif" alt="No image yet" class="cover_img"/>')

    img_class = 'cover_img'
    if zoom_level == ZOOM_SMALL:
        width = 100
        size = 'small'
        if revision.is_wraparound:
            img_class = 'wraparound_cover_img'
    elif zoom_level == ZOOM_MEDIUM:
        width = 200
        size = 'medium'
        if revision.is_wraparound:
            img_class = 'wraparound_cover_img'
    elif zoom_level == ZOOM_LARGE:
        width = 400
        size = 'large'

    if revision.changeset.state == states.APPROVED:
        current_cover = CoverRevision.objects.filter(cover=revision.cover, 
          changeset__state=states.APPROVED).order_by('-created')[0]
        if revision==current_cover: 
            # Current cover is the one from this revision, show it.
            return get_image_tag(revision.cover, esc(alt_text), zoom_level)  
        else: 
            # The cover was replaced by now, show original uploaded file,
            # scaled in the browser.
            # It is the real uploaded file for uploads on the new server, and
            # the large scan for older uploads, copied on replacement.
            suffix = "/uploads/%d_%s" % (revision.cover.id, 
                     revision.changeset.created.strftime('%Y%m%d_%H%M%S'))
            if revision.created > settings.NEW_SITE_COVER_CREATION_DATE:
                filename = glob.glob(revision.cover.base_dir() + suffix + '*')[0]
                file_extension = os.path.splitext(filename)[1]
            else:
                file_extension = ".jpg"
            # TODO:
            suffix = "%d/uploads/%d_%s" % (int(revision.cover.id/1000), 
                     revision.cover.id,
                     revision.changeset.created.strftime('%Y%m%d_%H%M%S'))
            img_url = settings.IMAGE_SERVER_URL + settings.COVERS_DIR +\
                      suffix + file_extension
            # for old covers do manual scaling, since it is the uploaded file
            return mark_safe('<img src="' + img_url + '" alt="' + \
              esc(alt_text) + '" width="' + str(width) + \
              '" class="' + img_class + '"/>')
    elif revision.deleted:
        return get_image_tag(revision.cover, esc(alt_text), zoom_level)  
    else:
        suffix = "w%d/%d.jpg" % (width, revision.id)
        img_url = NEW_COVERS_LOCATION + \
          revision.changeset.created.strftime('%B_%Y/').lower() + suffix
        return mark_safe('<img src="' + img_url + '" alt="' + esc(alt_text) \
               + '" ' + ' class="' + img_class + '"/>')
Пример #22
0
def show_country_info(country, name=None):
    if name:
        code = country
    else:
        code = country.code
        name = country.name
    src = u'src="%s/img/gcd/flags/%s.png"' % (settings.MEDIA_URL, code.lower())
    alt = u'alt="%s"' % esc(code.upper())
    title = u'title="%s"' % esc(name)
    return mark_safe(u'%s %s %s' % (src, alt, title))
Пример #23
0
def project_members(people):
    html = ['<ul class="unstyled project-members">']
    for person in people:
        d = {
            'url': esc(person.get_absolute_url()),
            'color': esc(person.color),
            'name': esc(person.name)
        }
        html.append(MEMBER_TAG % d)
    html.append('</ul>')
    return mark_safe('\n'.join(html))
Пример #24
0
 def full_name_with_link(self, publisher=False):
     if publisher:
         name_link = '<a href="%s">%s</a> (<a href="%s">%s</a>, %s%s series)' \
           % (self.get_absolute_url(), esc(self.name),
              self.publisher.get_absolute_url(), self.publisher,
              self.year_began,
              self._date_uncertain(self.year_began_uncertain))
     else:
         name_link = '<a href="%s">%s</a>' % (self.get_absolute_url(),
                                              esc(self.full_name()))
     return mark_safe(name_link)
Пример #25
0
 def full_name_with_link(self, publisher=False):
     if publisher:
         name_link = '<a href="%s">%s</a> (<a href="%s">%s</a>, %s%s series)' \
           % (self.get_absolute_url(), esc(self.name),
              self.publisher.get_absolute_url(), self.publisher,
              self.year_began,
              self._date_uncertain(self.year_began_uncertain))
     else:
         name_link = '<a href="%s">%s</a>' % (self.get_absolute_url(),
                                              esc(self.full_name()))
     return mark_safe(name_link)
Пример #26
0
def __format_credit(story, credit):
    if credit in ['script', 'pencils', 'inks', 'colors', 'letters', 'editing']:
        credit_value = __credit_value(story, credit, url=True)
    else:
        credit_value = getattr(story, credit)
    if not __credit_visible(credit_value):
        return ''

    if (credit == 'job_number'):
        label = _('Job Number')
    elif (credit == 'first_line'):
        label = _('First Line of Dialogue or Text')
    elif (credit == 'doi'):
        label = 'DOI'
    elif (credit == 'show_awards'):
        label = 'Awards'
    else:
        label = _(credit.title())

    if (credit in ['reprint_notes', 'reprint_original_notes']):
        label = _('Reprinted')
        values = split_reprint_string(credit_value)
        credit_value = '<ul>'
        for value in values:
            credit_value += '<li>' + esc(value)
        credit_value += '</ul>'
    elif credit == 'keywords':
        model_name = story._meta.model_name
        if model_name == 'issue' and story.series.is_singleton:
            keywords = story.keywords.all() | story.series.keywords.all()
        else:
            keywords = story.keywords
        credit_value = __format_keywords(keywords,
                                         model_name=model_name)
        if credit_value == '':
            return ''
    elif credit == 'feature_logo':
        label = _('Feature Logo')
        credit_value = esc(story.show_feature_logo())
        if credit_value == '':
            return ''
    else:  # This takes care of escaping the database entries we display
        credit_value = esc(credit_value)
    dt = '<dt class="credit_tag'
    dd = '<dd class="credit_def'
    if credit in ['genre', 'first_line', 'job_number', 'feature_logo']:
        dt += ' short'
        dd += ' short'
    dt += '">'
    dd += '">'

    return mark_safe(
           dt + '<span class="credit_label">' + label + '</span></dt>' +
           dd + '<span class="credit_value">' + credit_value + '</span></dd>')
Пример #27
0
def show_country_info(country, name=None):
    if name:
        code = country
    else:
        code = country.code
        name = country.name
    src = u'src="%s/img/gcd/flags/%s.png"' % (settings.MEDIA_URL,
                                              code.lower())
    alt = u'alt="%s"' % esc(code.upper())
    title = u'title="%s"' % esc(name)
    return mark_safe(u'%s %s %s' % (src, alt, title))
Пример #28
0
def login(request, template_name, landing_view='default_profile'):
    """
    Do some pre-checking before handing off to the standard login view.
    If anything goes wrong just let the standard login handle it.
    """

    if request.user.is_authenticated:
        return HttpResponseRedirect(urlresolvers.reverse(landing_view))

    try:
        if request.method == "POST":
            try:
                user = User.objects.get(email=request.POST['username'])
            except (User.DoesNotExist, User.MultipleObjectsReturned):
                user = User.objects.get(username=request.POST['username'])

            if user.indexer.registration_expires is not None:
                if date.today() > (user.indexer.registration_expires +
                                   timedelta(1)):
                    return render_error(
                        request,
                        ('The account with the email "%s" was never confirmed '
                         'and has expired.  You may <a href="' +
                         urlresolvers.reverse('register') +
                         '">re-register</a>.  ') % esc(user.email),
                        is_safe=True)
                return render_error(
                    request,
                    ('The account with email "%s" has not yet been confirmed. '
                     'You should receive an email that gives you a URL to visit '
                     'to confirm your account.  After you have visited that URL '
                     'you will be able to log in and use your account.  Please '
                     '<a href="mailto:%s">contact us</a> if you do not receive '
                     'the email within a few hours.') %
                    (esc(user.email), settings.EMAIL_CONTACT),
                    is_safe=True)

    except User.DoesNotExist:
        pass

    if 'next' in request.POST:
        next = request.POST['next']
        if re.match(r'/accounts/confirm/', next, flags=re.I):
            post = request.POST.copy()
            post['next'] = urlresolvers.reverse('welcome')
            request.POST = post
        if re.match(r'/gcd-error/', next, flags=re.I):
            post = request.POST.copy()
            post['next'] = urlresolvers.reverse('home')
            request.POST = post

    return LoginView.as_view(
        template_name=template_name,
        authentication_form=LongUsernameAuthenticationForm)(request)
Пример #29
0
def __format_keywords(keywords, join_on='; ', model_name='story'):
    if type(keywords) == str:
        credit_value = keywords
    else:
        keyword_list = list()
        for i in keywords.all().order_by('name'):
            keyword_list.append(
                '<a href="%s%s/">%s</a>' %
                (urlresolvers.reverse('show_keyword', kwargs={'keyword': i}),
                 esc(model_name), esc(i)))
        credit_value = join_on.join(str(i) for i in keyword_list)
    return mark_safe(credit_value)
def _find_publisher_object(request, changeset, name, publisher_objects,
                           object_type, publisher):
    if not name:
        return None, False

    publisher_objects = publisher_objects.filter(name__iexact=name)
    if publisher_objects.count() == 1:
        return publisher_objects[0], False
    else:
        error_text = '%s "%s" does not exist for publisher %s.' % \
          (object_type, esc(name), esc(publisher))
        return _handle_import_error(request, changeset, error_text)
Пример #31
0
def get_preview_image_tag(revision, alt_text, zoom_level):
    if revision is None:
        return mark_safe('<img class="no_cover" src="' + settings.MEDIA_URL + \
               'img/nocover.gif" alt="No image yet" class="cover_img"/>')

    if zoom_level == ZOOM_SMALL:
        width = 100
        size = 'small'
    elif zoom_level == ZOOM_MEDIUM:
        width = 200
        size = 'medium'
    elif zoom_level == ZOOM_LARGE:
        width = 400
        size = 'large'
    width_string = 'width="' + str(width) + '"'

    if revision.changeset.state == states.APPROVED:
        current_cover = CoverRevision.objects.filter(
            cover=revision.cover,
            changeset__state=states.APPROVED).order_by('-created')[0]
        if revision == current_cover:
            # Current cover is the one from this revision, show it.
            return get_image_tag(revision.cover, esc(alt_text), zoom_level)
        else:
            # The cover was replaced by now, show original uploaded file,
            # scaled in the browser.
            # It is the real uploaded file for uploads on the new server, and
            # the large scan for older uploads, copied on replacement.
            suffix = "/uploads/%d_%s" % (
                revision.cover.id,
                revision.changeset.created.strftime('%Y%m%d_%H%M%S'))
            if revision.created > datetime(2009, 10, 2, 14, 0, 0):
                filename = glob.glob(revision.cover.base_dir() + suffix +
                                     '*')[0]
                file_extension = os.path.splitext(filename)[1]
            else:
                file_extension = ".jpg"
            # TODO:
            suffix = "%d/uploads/%d_%s" % (
                int(revision.cover.id / 1000), revision.cover.id,
                revision.changeset.created.strftime('%Y%m%d_%H%M%S'))
            img_url = settings.IMAGE_SERVER_URL + settings.COVERS_DIR +\
                      suffix + file_extension
            return mark_safe('<img src="' + img_url + '" alt="' + \
              esc(alt_text) + '" ' + width_string + ' class="cover_img"/>')
    elif revision.deleted:
        return get_image_tag(revision.cover, esc(alt_text), zoom_level)
    else:
        suffix = "w%d/%d.jpg" % (width, revision.id)
        img_url = NEW_COVERS_LOCATION + \
          revision.changeset.created.strftime('%B_%Y/').lower() + suffix
        return mark_safe('<img src="' + img_url + '" alt="' + esc(alt_text) \
               + '" ' + width_string + ' class="cover_img"/>')
Пример #32
0
 def get_compare_string(self, base_issue):
     if self.target_issue == base_issue:
         reprint = u'from %s <i>sequence</i> <a target="_blank" href="%s#%d">%s</a>' % \
                     (self.origin.issue.get_absolute_url(), 
                     esc(self.origin.issue.full_name()), self.origin.id, esc(self.origin))
     else:
         reprint = u'in <a target="_blank" href="%s">%s</a>' % \
                     (self.target_issue.get_absolute_url(),
                      esc(self.target_issue.full_name()))
     if self.notes:
         reprint = u'%s [%s]' % (reprint, esc(self.notes))
     return mark_safe(reprint)
Пример #33
0
 def get_compare_string(self, base_issue):
     if self.origin_issue == base_issue:
         direction = 'in'
         issue = self.target_issue
     else:
         direction = 'from'
         issue = self.origin_issue
     reprint = u'%s <a target="_blank" href="%s">%s</a>' % \
                 (direction, issue.get_absolute_url(), esc(issue.full_name()))
     if self.notes:
         reprint = u'%s [%s]' % (reprint, esc(self.notes))
     return mark_safe(reprint)
Пример #34
0
def _find_publisher_object(request, changeset, name, publisher_objects,
                           object_type, publisher):
    if not name:
        return None, False

    publisher_objects = publisher_objects.filter(name__iexact=name)
    if publisher_objects.count() == 1:
        return publisher_objects[0], False
    else:
        error_text = '%s "%s" does not exist for publisher %s.' % \
          (object_type, esc(name), esc(publisher))
        return _handle_import_error(request, changeset, error_text)
Пример #35
0
def show_issue(issue):
    if issue.display_number:
        issue_number = '%s' % (esc(issue.display_number))
    else:
        issue_number = ''
    if issue.variant_name:
        issue_number = '%s [%s]' % (issue_number, esc(issue.variant_name))
    if issue_number:
        issue_number = '<a href="%s">%s</a>' % (issue.get_absolute_url(),
                                                issue_number)
    return mark_safe('<a href="%s">%s</a> (%s series) %s' %
                     (issue.series.get_absolute_url(), esc(issue.series.name),
                      esc(issue.series.year_began), issue_number))
 def get_compare_string(self, base_issue):
     if self.origin.issue == base_issue:
         direction = 'in'
         story = self.target
     else:
         direction = 'from'
         story = self.origin
     reprint = u'%s %s <i>sequence</i> <a target="_blank" href="%s#%d">%s</a>' % \
                 (direction, story.issue.get_absolute_url(), 
                 esc(story.issue.full_name()), story.id, esc(story))
     if self.notes:
         reprint = u'%s [%s]' % (reprint, esc(self.notes))
     return mark_safe(reprint)
Пример #37
0
def add_single_issue_to_collection(request, issue_id):
    issue = Issue.objects.get(id=issue_id)
    collection, error_return = get_collection_for_owner(request,
                   collection_id=int(request.POST['collection_id']))
    if not collection:
        return error_return
    collected = create_collection_item(issue, collection)
    messages.success(request, u"Issue <a href='%s'>%s</a> was added to your "
                               "'%s' collection." % \
                              (collected.get_absolute_url(collection),
                               esc(issue), esc(collection.name)))
    return HttpResponseRedirect(urlresolvers.reverse('show_issue',
                                  kwargs={'issue_id': issue_id}))
Пример #38
0
def generate_candidates_link(story, reprint_string, candidates, from_to, style):
    """ generate links for candidate reprints to_issue"""

    link = "<li>" + esc(reprint_string) + "\t candidate(s):\n"
    for i in candidates:
        link += generate_reprint_link(story, i, from_to, style, li=False)
        link += (
            '\n editors please edit the <a target="_blank" href="http://www.comics.org/admin/system/modules/site.lasso?mode=update&type=story&storyid='
            + esc(story.id)
            + '">database</a>\n'
        )
    link += "</li>"
    return link
Пример #39
0
def generate_reprint_link(from_story,
                          to_issue,
                          from_to,
                          style,
                          notes=None,
                          li=True):
    ''' generate reprint link to_issue'''

    link = "<a href=\"/gcd/issue/" + str(to_issue.id)
    sequence = find_reprint_sequence_in_issue(from_story, to_issue.id)
    link += "?style=" + style + "&reprints=True"
    if (sequence >= 0):
        link += "#" + esc(sequence)
    link += "\">"
    #    link += "?style=" + style + "&reprints=True\">"

    link += esc(from_to) + esc(to_issue.series.name)
    link += " (" + esc(to_issue.series.publisher) + ", "
    link += esc(to_issue.series.year_began) + " series) #"
    link += esc(to_issue.number) + "</a>"
    if notes:
        link += esc(notes)
    link += " (" + esc(to_issue.publication_date) + ")"
    if li:
        return '<li> ' + link + ' </li>'
    else:
        return link
Пример #40
0
def show_diff(diff_list, change):
    """show changes in diff with markings for add/delete"""
    compare_string = ""
    span_tag = "<span class='%s'>%s</span>"
    if change == "orig":
        for i in diff_list:
            if i[0] == 0:
                compare_string += esc(i[1])
            elif i[0] == -1:
                compare_string += span_tag % ("deleted", esc(i[1]))
            elif i[0] == -2:
                compare_string += esc(i[1]) + "</span>"
            elif i[0] == -3:
                compare_string += esc(i[1])
    else:
        for i in diff_list:
            if i[0] == 0:
                compare_string += esc(i[1])
            elif i[0] == 1:
                compare_string += span_tag % ("added", esc(i[1]))
            elif i[0] == 2:
                compare_string += esc(i[1]) + "</span>"
            elif i[0] == 3:
                compare_string += esc(i[1])
    return mark_safe(compare_string)
Пример #41
0
	def formatday(self, day, weekday):
		if day != 0:
			tomorrow = date(self.year, self.month, day) + timedelta(days=1)
			cssclass = self.cssclasses[weekday]
			if date.today() == date(self.year, self.month, day):
				cssclass += ' today'
				today = True
			else:
				today = False
			if day in self.reservations:
				body = ['<ul>']
				num_today = len(self.reservations[day])
				num_private = 0
				num_shared = 0
				this_date = date(self.year, self.month, day)
				any_availability = Room.objects.free(this_date, tomorrow)
				print this_date
				print tomorrow
				print any_availability
				if not any_availability:
					cssclass += ' full-today'
				for reservation in self.reservations[day]:
					if reservation.room.shared:
						num_shared += 1
						room_type = "S"
					else:
						num_private += 1
						room_type = "P"

					body.append('<li id="res%d-cal-item">' %reservation.id)
					if reservation.status == Reservation.APPROVED:
						body.append('<a href="#reservation%d" class="greyed-out">' % reservation.id)
					else:
						body.append('<a href="#reservation%d">' % reservation.id)				
					if reservation.hosted:
						body.append(esc("%s (%s)" % (reservation.guest_name.title(), room_type)))
					else:
						body.append(esc("%s (%s)" % (reservation.user.first_name.title(), room_type)))
					body.append('</a>')
					if reservation.arrive.day == day:
						body.append('<em> (Arrive)</em>') 					
					if reservation.depart == tomorrow:
						body.append('<em> (Last night)</em>')					
					body.append('</li>')
					body.append('</span>')
				body.append('</ul>')
				body.append("<span class='cal-day-total'>total %d (P: %d/S: %d)</span>" % (num_today, num_private, num_shared))
				return self.day_cell(cssclass, '%d %s' % (day, ''.join(body)))
			return self.day_cell(cssclass, day)
		return self.day_cell('noday', '&nbsp;')
Пример #42
0
def short_label(query_obj):
    # Collect the output
    output = []
    icon = '<i class="icon-{}"></i>'
    # Split the query into each journal
    for query in query_obj["queries"]:
        text = query.get("text", "")
        line_bits = [icon.format(esc(query.get("type", "")))]
        # Check if the journal name is longer than we want
        if len(text) <= 15:
            line_bits.append(esc(text))
        else:
            line_bits.extend(['<span title="', esc(text), '">', esc(text[0:13]), "&hellip;</span>"])
        output.append("".join(line_bits))
    return mark_safe("<br />".join(output))
Пример #43
0
def add_single_issue_to_collection(request, issue_id):
    issue = Issue.objects.get(id=issue_id)
    collection = get_collection_for_owner(request,
                   collection_id=int(request.POST['collection_id']))
    collected = CollectionItem.objects.create(issue=issue)
    collected.collections.add(collection)
    if collection.own_used:
        collected.own = collection.own_default
        collected.save()
    messages.success(request, u"Issue <a href='%s'>%s</a> was added to your "
                               "'%s' collection." % \
                              (collected.get_absolute_url(collection),
                               esc(issue), esc(collection.name)))
    return HttpResponseRedirect(urlresolvers.reverse('show_issue',
                                  kwargs={'issue_id': issue_id}))
Пример #44
0
def show_issue(issue):
    if issue.display_number:
        issue_number = '%s' % (esc(issue.display_number))
    else:
        issue_number = ''
    if issue.variant_name:
        issue_number = '%s [%s]' % (issue_number, esc(issue.variant_name))
    if issue_number:
        issue_number = '<a href="%s">%s</a>' % (issue.get_absolute_url(),
                                                issue_number)
    return mark_safe('<a href="%s">%s</a> (%s series) %s' %
                     (issue.series.get_absolute_url(),
                      esc(issue.series.name),
                      esc(issue.series.year_began),
                      issue_number))
Пример #45
0
def follow_reprint_link(reprint, direction, level=0):
    if level > 10:  # max level to avoid loops
        return ''
    reprint_note = ''
    if direction == 'from':
        if type(reprint.origin) == Story:
            further_reprints = list(
                reprint.origin.from_reprints.select_related(
                    'origin__issue__series__publisher').all())
        else:
            further_reprints = list(reprint.origin.from_reprints.all())
        further_reprints.extend(
            list(
                reprint.origin.from_issue_reprints.select_related(
                    'origin_issue__series__publisher').all()))
        further_reprints = sorted(further_reprints,
                                  key=lambda a: a.origin_sort)
        reprint_note += generate_reprint_notes(from_reprints=further_reprints,
                                               level=level)
        if reprint.origin.reprint_notes:
            for string in split_reprint_string(reprint.origin.reprint_notes):
                string = string.strip()
                if string.lower().startswith('from '):
                    reprint_note += '<li> ' + esc(string) + ' </li>'
    else:
        if type(reprint.target) == Story:
            further_reprints = list(
                reprint.target.to_reprints.select_related(
                    'target__issue__series__publisher').all())
        else:
            further_reprints = list(reprint.target.to_reprints.all())
        further_reprints.extend(
            list(
                reprint.target.to_issue_reprints.select_related(
                    'target_issue__series__publisher').all()))
        further_reprints = sorted(further_reprints,
                                  key=lambda a: a.target_sort)
        reprint_note += generate_reprint_notes(to_reprints=further_reprints,
                                               level=level)
        if reprint.target.reprint_notes:
            for string in split_reprint_string(reprint.target.reprint_notes):
                string = string.strip()
                if string.lower().startswith('in '):
                    reprint_note += '<li> ' + esc(string) + ' </li>'

    if reprint_note != '':
        reprint_note = 'which is reprinted<ul>%s</ul>' % reprint_note
    return reprint_note
Пример #46
0
def show_issue_number(issue_number):
    """ Return issue number, but maybe not """
    if issue_number == 'nn' or issue_number == '[nn]':
        return ''
    else:
        return mark_safe('<span id="issue_number"><span class="p">#</span>' + \
            esc(issue_number) + '</span>')
Пример #47
0
    def formatday(self, day, weekday):
        if day != 0:
            cssclass = self.cssclasses[weekday]
            if date.today() == date(self.year, self.month, day):
                cssclass += ' today'
                body = '<a class="tipsy" href="#" title="%s">%d</a>' % (
                    _('Today'), day)
                if day in self.events:
                    d = reverse('events_day',
                                args=[self.year, self.month, day])
                    body = '<a class="tipsy" href="%s" title="%s">%d</a>' % (
                        d, _("Events found"), day)
                return self.day_cell(cssclass, body)

            if day in self.events:
                cssclass += ' filled'
                title = ['<ul class=event>']
                for event in self.events[day]:
                    title.append('<li><b>%s</b></li>' % esc(event.name))
                title.append('</ul>')
                d = reverse('events_day', args=(self.year, self.month, day))
                body = '<a class="tipsy" href="%s" title="%s">%d</a>' % (
                    d, _("Events found"), day)
                return self.day_cell(cssclass, body)
            return self.day_cell(cssclass, day)
        return self.day_cell('noday', '&nbsp;')
Пример #48
0
def dependency_data(form):
    """Render the data-bob-dependencies tag if this is a DependencyForm"""

    if not isinstance(form, DependencyForm):
        return ''
    return 'data-bob-dependencies="{0}"'.format(
        esc(json.dumps(form.get_dependencies_for_js())))
Пример #49
0
def get_civilian_identity(character,
                          appearing_characters,
                          url=True,
                          compare=False):
    civilian_identity = set(
        character.character.character.to_related_character
                 .filter(relation_type__id=2).values_list('to_character',
                                                          flat=True))\
                 .intersection(appearing_characters.values_list(
                               'character__character', flat=True))
    if civilian_identity:
        civilian_identity = appearing_characters.filter(
            character__character__id=civilian_identity.pop())
        characters = ' ['
        several = False
        for identity in civilian_identity:
            if several:
                characters += '; '
            if url:
                characters += '<a href="%s">%s</a>' % (
                    identity.character.get_absolute_url(),
                    esc(identity.character.name))
            else:
                characters += '%s' % identity.character.name
            if compare:
                return ' [%s]' % identity.character.character.disambiguated
            several = True
        characters += ']'
        return characters
    else:
        return ''
Пример #50
0
def show_feature(story):
    first = True
    features = ''
    for feature in story.feature_object.all():
        if first:
            first = False
        else:
            features += '; '
        features += '<a href="%s">%s</a>' % (feature.get_absolute_url(),
                                             esc(feature.name))
    if story.feature:
        if features:
            features += '; %s' % esc(story.feature)
        else:
            features = esc(story.feature)
    return mark_safe(features)
Пример #51
0
def __format_keywords(keywords, join_on='; '):
    if type(keywords) == unicode:
        credit_value = keywords
    else:
        credit_value = esc(
            join_on.join(str(i) for i in keywords.all().order_by('name')))
    return credit_value
Пример #52
0
def show_reprints(story):
    """ Filter for our reprint line on the story level."""
    from_reprints = story.from_all_reprints \
                         .select_related('origin_issue__series__publisher')\
                         .order_by('origin_issue__key_date')
    reprint = generate_reprint_notes(from_reprints=from_reprints)

    if story.type.id not in [STORY_TYPES['preview'],
                             STORY_TYPES['comics-form ad']]:
        no_promo = True
    else:
        no_promo = False
    to_reprints = story.to_all_reprints\
                       .select_related('target_issue__series__publisher')\
                       .order_by('target_issue__key_date')
    reprint += generate_reprint_notes(to_reprints=to_reprints,
                                      no_promo=no_promo)

    if story.reprint_notes:
        for string in split_reprint_string(story.reprint_notes):
            string = string.strip()
            reprint += '<li> ' + esc(string) + ' </li>'

    if reprint != '':
        label = _('Reprints')
        return mark_safe('<dt class="credit_tag">' +
                         '<span class="credit_label">' + label +
                         '</span></dt>' + '<dd class="credit_def">' +
                         '<span class="credit_value">' +
                         '<ul>' + reprint + '</ul></span></dd>')
    else:
        return ""
Пример #53
0
def show_reprints(story):
    """ Filter for our reprint line on the story level."""

    reprint = ""

    from_reprints = list(story.from_reprints.select_related().all())
    from_reprints.extend(list(
        story.from_issue_reprints.select_related().all()))
    from_reprints = sorted(from_reprints, key=lambda a: a.origin_sort)
    reprint = generate_reprint_notes(from_reprints=from_reprints)

    if story.type.id != STORY_TYPES['preview']:
        no_promo = True
    else:
        no_promo = False
    to_reprints = list(story.to_reprints.select_related().all())
    to_reprints.extend(list(story.to_issue_reprints.select_related().all()))
    to_reprints = sorted(to_reprints, key=lambda a: a.target_sort)
    reprint += generate_reprint_notes(to_reprints=to_reprints,
                                      no_promo=no_promo)

    if story.reprint_notes:
        for string in split_reprint_string(story.reprint_notes):
            string = string.strip()
            reprint += '<li> ' + esc(string) + ' </li>'

    if reprint != '':
        label = _('Reprints')
        return mark_safe('<dt class="credit_tag">' +
                         '<span class="credit_label">' + label +
                         '</span></dt>' + '<dd class="credit_def">' +
                         '<span class="credit_value">' + '<ul>' + reprint +
                         '</ul></span></dd>')
    else:
        return ""
Пример #54
0
Файл: views.py Проект: hop/mos
 def formatday(self, day, weekday):
     if day != 0:
         d = date(self.year, self.month, day)
         d1 = d + relativedelta.relativedelta(days=1)  # next day
         cssclass = self.cssclasses[weekday]
         if date.today() == date(self.year, self.month, day):
             cssclass += ' today'
             cssclass += ' filled'
         body = ['<ul>']
         for event in self.events.exclude(startDate__gt=d1).exclude(
                 endDate__lt=d,
                 endDate__isnull=False).exclude(endDate__isnull=True,
                                                startDate__lt=d):
             body.append('<li>')
             body.append('<a href="/wiki/%s">' % event.wikiPage)
             body.append(
                 event.startDate.strftime('%H:%M') + ' ' + esc(event.name))
             body.append('</a>')
             if self.admin:
                 body.append(u'<a href="%s" class="edit">/e</a>' %
                             event.get_absolute_url())
             body.append('</li>')
         body.append('</ul>')
         return self.day_cell(
             cssclass, '%d %s' % (day, (u''.join(body)).encode('utf-8')))
         return self.day_cell(cssclass, day)
     return self.day_cell('noday', '&nbsp;')
 def formatday(self, day, weekday):
     #Check the day
     if day != 0:
         #Get the css classes.
         cssclass = self.cssclasses[weekday]
         #Add a highlighter for this day.
         if date.today() == date(self.year, self.month, day):
             cssclass += ' today'
         #If there is a meeting on the day, highlight that day.
         if day in self.meetings:
             #Add the class that fills the day.
             cssclass += ' filled'
             #Add a list with links for the 
             #       meetings on that day.
             body = ['<ul>']
             #Loop through the meetings and 
             #       add them to the list.
             for meeting in self.meetings[day]:
                 #Open list tag.
                 body.append('<li>')
                 #Close the append tag.
                 body.append('<a href="javascript:view_meeting(\'%s\');" class="meeting_link" title="Click to view \'%s\'. %s topics.">'%(meeting.publicid,meeting.name,len(meeting.topics.all())))
                 #Output the meeting.
                 body.append(esc(meeting.name))
                 #Close the link and the list tag.
                 body.append('</a></li>')
             #Close the list.
             body.append('</ul>')
             #Return the day cell.
             return self.day_cell(cssclass, '%d %s' % (day, ''.join(body)),day)
         #Return the cssclass cell.
         return self.day_cell(cssclass, day, day)
     #Return just a normal cell.
     return self.day_cell('noday', '&nbsp;', day)
Пример #56
0
 def formatday(self, day, weekday):
     if day != 0:
         cssclass = self.cssclasses[weekday]
         if date.today() == date(self.year, self.month, day):
             cssclass += ' today'
         if day in self.events:
             cssclass += ' filled'
             if self.size == 'large':
                 body = ['<ul>']
                 for event in self.events[day]:
                     body.append('<li>')
                     body.append('<a href="%s">' % event.get_absolute_url())
                     body.append(esc(event.event.title))
                     body.append('</a></li>')
                     body.append('</ul>')
                 return self.day_cell(cssclass,
                                      '%d %s' % (day, ''.join(body)))
             else:
                 for event in self.events[day]:
                     body = [
                         '<a href="%s"><div class="%s">%d</div></a>' %
                         (event.get_absolute_url(),
                          event.event.calendar.slug, day)
                     ]
                 return self.day_cell(cssclass, '%s' % ''.join(body))
         return self.day_cell(
             cssclass,
             '%d %s' % (day, ''.join('<div class="noevents"></div>')))
     return self.day_cell('noday', '&nbsp;')