Beispiel #1
0
def data_check(django_request):

    config_data = model.configuration.get_config()
    model.database.database_init(config_data)

    viewer = model.person.Person.find(django_request.user.link_id)

    params = django_request.GET

    duplicate_profiles = model.database.check_for_duplicates(
        'profiles', 'people')

    page_data = model.pages.HtmlPage(
        "Data check",
        pages.page_pieces.top_navigation(django_request),
        django_request=django_request)
    page_data.add_content(
        str(len(duplicate_profiles)) +
        " people with multiple profiles (by name)",
        model.pages.with_help(viewer, [
            T.dl[[[
                T.dt[k, " (",
                     str(len(duplicate_profiles[k])), " profiles)"],
                T.dd[T.ul[[
                    T.li[T.div(class_='identifying')["Profile: ", T.pre[p[0]]],
                         T.br,
                         T.div(class_='operational')["Operational: ",
                                                     T.pre[p[1] or "None"]]]
                    for p in duplicate_profiles[k]
                ]]]
            ] for k in sorted(duplicate_profiles.keys())]]
        ], "duplicate_profiles_list"))
    return HttpResponse(str(page_data.to_string()))
Beispiel #2
0
 def to_string(self):
     user = self.viewer or (model.person.Person.find(
         self.django_request.user.link_id) if self.django_request else None)
     if user:
         model.database.log_machine_use("makers",
                                        user._id if user else None,
                                        details=self.name)
     index = [
         T.div(class_="tabset")[[
             T.button(
                 class_="tablinks",
                 onclick=(("openLazyTab(event, '" + section_id + "', '" +
                           self.sections[section_id] + "')") if isinstance(
                               self.sections[section_id], str) else
                          ("openTab(event, '" + section_id + "')")),
                 id=section_id +
                 "_button")[self.presentation_names[section_id]]
             for section_id in self.index
         ]],
         T.br(clear='all')
     ]
     tabs = [[
         T.div(class_="tabcontent",
               id_=section_id)[self.sections[section_id]]
     ] for section_id in self.index]
     return page_string(
         self.name,
         self.top_content + [
             T.div(class_="tabbedarea")[index,
                                        [T.div(class_="tabcontents")[tabs]]]
         ],
         user=user,
         initial_tab=(self.initial_tab +
                      "_button") if self.initial_tab else None,
         needs_jquery=self.lazy)
Beispiel #3
0
def with_help(who, content, help_name, substitutions={}):
    if not who.show_help:
        return content
    help_text = help_for_topic(help_name,
                               default_text="",
                               substitutions=substitutions)
    if help_text:
        return T.div(class_="with_help")[
            T.div(class_="helped")[content],
            T.div(class_="help")[untemplate.safe_unicode(help_text)]]
    else:
        return content
def avail_table(who, slot_sums):
    days, _, times = model.timeslots.get_slots_conf()
    return [T.div(class_="avail_table")[
        [T.h4["Availability of people who have requested training"],
         T.table(class_="availability")
         [T.thead[T.tr[T.th(class_="daylabel")["Day"],
                       [[T.th[slotname]] for slotname in times]]],
          T.tbody[[[T.tr[T.th(class_="daylabel")[day],
                         [T.td[str(b) # todo: make bold, and a different style, if "who" (the viewing user) is available then
                           ]
                          for t, b in zip(times, day_slots)]]]
                   for (day, day_slots) in zip(days,
                                               model.timeslots.avsums_by_day(slot_sums))]]]]]]
def availform(who, available, django_request):
    days, _, times = model.timeslots.get_slots_conf()
    return (T.div(class_="availability")
            [T.form(action=django.urls.reverse("dashboard:update_availability"),
                    method="POST")
             [T.table(class_="availability")
              [[T.thead[T.tr[T.th(class_="daylabel")["Day"],
                             [[T.th[slotname]] for slotname in times]]]],
               T.tbody[[[T.tr[T.th(class_="daylabel")[day],
                              [T.td[T.input(type="checkbox",
                                            name=day+"_"+t, checked="checked")
                                    if b
                                    else T.input(type="checkbox",
                                                 name=day+"_"+t)]
                               for t, b in zip(times, day_slots)]]]
                        for (day, day_slots) in zip(days,
                                                    model.timeslots.timeslots_from_int(available))]]],
              T.input(type="hidden", name="csrfmiddlewaretoken", value=django.middleware.csrf.get_token(django_request)),
              T.input(type='hidden', name='person', value=str(who._id)),
              T.input(type="submit", value="Update availability")]])
def interests_section(interest_levels, mail_levels, django_request, for_person=None):
    interest_areas = model.configuration.get_config('interest_areas')
    if interest_areas is None:
        return []
    existing_interests = {area_name: interest_levels.get(area_name, 0) for area_name in interest_areas}
    return [T.form(action=django.urls.reverse("dashboard:update_levels"), method="POST")
            [T.table(class_="interests_check_table")
             [T.thead[T.tr[[T.th["Area"],
                            [[[T.th(class_='level_'+str(lev))[str(lev)]] for lev in range(4)]]]]],
              T.tbody[[[T.tr[T.th[area],
                             [[[interests_button(area, existing_interests[area], lev)] for lev in range(4)]]]]
                       for area in sorted(interest_areas)]],
              (T.tfoot[T.tr[T.th["Mail me about events"],
                            T.td[""],
                            [[[T.td[(T.input(type='checkbox', name='mail_'+str(lev), checked='checked')
                                     if mail_levels[lev]
                                     else T.input(type='checkbox', name='mail_'+str(lev)))]] for lev in range(1,4)]]]] if mail_levels else "")],
             T.input(type="hidden", name="csrfmiddlewaretoken", value=django.middleware.csrf.get_token(django_request)),
             # This form can be used either for a person, or for an event
             T.input(type='hidden', name='subject_user_uuid', value=for_person._id) if for_person else "",
             T.div(align="right")[T.input(type="submit", value="Update interests")]],
            T.input(type="hidden", name="csrfmiddlewaretoken", value=django.middleware.csrf.get_token(django_request))]
Beispiel #7
0
def invitation_response_form_page(rsvp_uuid):
    """From an invitation UUID that was mailed to someone, produce a response form."""
    global server_conf
    server_conf = configuration.get_config('server')
    page_pieces.set_server_conf()
    person_responding = person.Person.find(database.find_rsvp(rsvp_uuid))
    # set up viewing as though the user has actually logged in
    access_permissions.Access_Permissions.setup_access_permissions(person_responding.link_id)
    # todo: also tell django that they are effectively logged in?
    event_responding = event.Event.find_by_id(person_responding.invitations[rsvp_uuid])
    form_act = django.urls.reverse("events:rsvp_form", args=[rsvp_uuid])
    return T.div(class_="invitresp")[
        T.h1["RSVP for " + person_responding.name(access_permissions_event=event_responding)],
        T.p["This is a " + event_responding.event_type
            + " event starting at " + str(event_responding.start)
            + ".  The event will be hosted by "
            + ". and ".join([obj.name(access_permissions_role='host')
                             for obj in event_responding.hosts
                             if obj is not None])
            + "."],
        T.form(action=form_act,
               method='POST')[
            T.input(type="hidden",
                    name="rsvp_uuid",
                    value=rsvp_uuid),
            T.table[T.tr[T.td[T.input(type='radio',
                                      name='rsvp',
                                      value='accept')],
                         T.td["Accept invitation"]],
                    T.tr[T.td[T.input(type='radio',
                                      name='rsvp',
                                      value='decline')],
                         T.td["Decline invitation"]],
                    T.tr[T.td[T.input(type='radio',
                                      name='rsvp',
                                      value='drop')],
                         T.td["Decline invitation and cancel training request"]]],
            T.input(type="submit", value="Send response")]]
Beispiel #8
0
def expandable_section(section_id, section_tree):
    # from https://stackoverflow.com/questions/16308779/how-can-i-hide-show-a-div-when-a-button-is-clicked
    return [
        T.button(onclick="toggle_visibility(section_id);")["Toggle"],
        T.div(id_=section_id)[section_tree]
    ]