示例#1
0
    def test_long_description(self, client, derrida):
        """project detail page should display long description (body) if set"""
        # set a long description for derrida
        derrida.body = to_streamfield_safe("<b>About Derrida</b>")
        derrida.save()

        # should display with rich text
        response = client.get(derrida.get_url())
        assertContains(response, "<b>About Derrida</b>", html=True)
示例#2
0
def make_staffer_profile(people_landing_page, staffer):
    """Create a profile page for a given staff person."""
    profile = Profile(
        person=staffer,
        title="Staffer",
        education="Princeton University",
        body=to_streamfield_safe(
            "<p>I'm a member of the CDH staff. I do digital humanities.</p>"),
    )
    people_landing_page.add_child(instance=profile)
    people_landing_page.save()
    return profile
示例#3
0
def make_announcement(blog_link_page):
    """Create an announcement published in 2020 with no author."""
    pubdate = timezone.datetime(2020, 11, 2, 15, tzinfo=EST).astimezone(tz.utc)
    post = BlogPost(
        title="A Big Announcement!",
        body=to_streamfield_safe(
            "<p>We're making a big digital humanities announcement.</p>"
        ),
    )
    blog_link_page.add_child(instance=post)
    blog_link_page.save()
    post.first_published_at = pubdate
    post.last_published_at = pubdate
    post.save()
    return post
示例#4
0
def make_deadline(link_page):
    """Create a deadline set for 2099."""
    deadline_type = EventType.objects.get_or_create(name="Deadline")[0]
    start_time = timezone.datetime(2099, 1, 1, tzinfo=EST).astimezone(tz.utc)
    end_time = timezone.datetime(2099, 1, 1, tzinfo=EST).astimezone(tz.utc)
    deadline = Event(
        title="testing deadline",
        body=to_streamfield_safe("<p>An important due date in the far future!</p>"),
        start_time=start_time,
        end_time=end_time,
        type=deadline_type,
    )
    deadline.last_published_at = start_time - timedelta(days=10)
    link_page.add_child(instance=deadline)
    link_page.save()
    return deadline
示例#5
0
def make_course(link_page):
    """Create a course that happened spring 2017."""
    course_type = EventType.objects.get_or_create(name="Course")[0]
    start_time = timezone.datetime(2017, 2, 2, tzinfo=EST).astimezone(tz.utc)
    end_time = timezone.datetime(2017, 4, 27, tzinfo=EST).astimezone(tz.utc)
    course = Event(
        title="testing course",
        body=to_streamfield_safe("<p>February 2017 Intro to Digital Humanities</p>"),
        start_time=start_time,
        end_time=end_time,
        type=course_type,
    )
    course.last_published_at = start_time - timedelta(days=10)
    link_page.add_child(instance=course)
    link_page.save()
    return course
示例#6
0
def make_project_feature(blog_link_page, grad_pm):
    """Create a sponsored project feature by a grad PM published in 2018."""
    pubdate = timezone.datetime(2018, 5, 19, 17, 31, tzinfo=EST).astimezone(tz.utc)
    post = BlogPost(
        title="Making progress on the Cool Project",
        body=to_streamfield_safe(
            "<p>the Cool Digital Project is getting cooler every day</p>"
        ),
    )
    blog_link_page.add_child(instance=post)
    blog_link_page.save()
    post.first_published_at = pubdate
    post.last_published_at = pubdate
    post.save()
    Author.objects.create(person=grad_pm, post=post)
    return post
示例#7
0
def make_workshop(link_page, cdh_location):
    """Create a 2hr workshop at the CDH that happened in 2019."""
    workshop_type = EventType.objects.get_or_create(name="Workshop")[0]
    start_time = timezone.datetime(2019, 10, 5, 9, tzinfo=EST).astimezone(tz.utc)
    end_time = timezone.datetime(2019, 10, 5, 11, tzinfo=EST).astimezone(tz.utc)
    workshop = Event(
        title="testing workshop",
        body=to_streamfield_safe("<p>Digital Mapping workshop for 2019</p>"),
        start_time=start_time,
        end_time=end_time,
        location=cdh_location,
        type=workshop_type,
    )
    workshop.last_published_at = start_time - timedelta(days=10)
    link_page.add_child(instance=workshop)
    link_page.save()
    return workshop
示例#8
0
def add_upcoming_event(link_page):
    """Create a course that will happen in 2080. This second course is not defined
    as a fixture since it only needs to be called once."""
    course_type = EventType.objects.get_or_create(name="Course")[0]
    start_time = timezone.datetime(2080, 2, 2).astimezone(tz.utc)
    end_time = timezone.datetime(2080, 4, 27).astimezone(tz.utc)
    course = Event(
        title="second testing course",
        body=to_streamfield_safe("<p>February 2080 History of Digital Humanities</p>"),
        start_time=start_time,
        end_time=end_time,
        type=course_type,
    )
    course.last_published_at = start_time - timedelta(days=10)
    link_page.add_child(instance=course)
    link_page.save()
    return course
示例#9
0
def make_article(blog_link_page, staffer, postdoc):
    """Create article by staff member and postdoc from 2019; updated in 2020"""
    in_2019 = timezone.datetime(2019, 3, 4, 8, 25, tzinfo=EST).astimezone(tz.utc)
    in_2020 = timezone.datetime(2020, 1, 15, 20, 12, tzinfo=EST).astimezone(tz.utc)
    post = BlogPost(
        title="We wrote an article together, and it got published on the CDH website",
        body=to_streamfield_safe(
            "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>"
        ),
    )
    blog_link_page.add_child(instance=post)
    blog_link_page.save()
    post.first_published_at = in_2019
    post.last_published_at = in_2020
    post.save()
    Author.objects.create(person=staffer, post=post)
    Author.objects.create(person=postdoc, post=post)
    return post