예제 #1
0
    def GET(self):
        context = Storage(
            title=_("List of points"),
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",                 
            ), 
        )

        page_nav_data = Storage(
            nav_data = nav_data(
                add=links.add_point,
                loc=links.place,
                hom=links.home,
                sea=links.search,
                inf=None,
            ),
        )


        context.page_nav_data = page_nav_data
        context.about = model.doc_helper(context, "about", i18n.getLanguage())

        get_page('info', context)
예제 #2
0
    def GET(self, topic_id): 
        topics, topic = model.t_helper(topic_id)

        webinput = web.input()

        context = Storage(title=_(self.title),
                          widgetizer_link=pc_links(self.widgetizer_link, topic_id),
                          help_link=pc_links('guide', 'help_' + self.widget_link),
                        )
        form = self.get_form(topic=topic)

        if not webinput.has_key("from_widget") or not form.validates():
            get_page("widgetize", context, topic, form)
        else:
            #d = Storage()
            #for k in form.d:
            #    if form.d[k]:
            #        d[k] = form.d[k]
            widget_link = widget_links(self.widget_link, topic.id, **form.d)
            result = Storage(
                link=widget_link,
                link_len=len(widget_link),
                height=form.d.height,
                width=form.d.width,
            )
            result.id = form.d.get("id", "")
            get_page("widgetize", context, topic, form, result=result)
예제 #3
0
    def GET(self):
        context = Storage(
            title=_("List of points"),
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",                 
            ), 
        )

        page_nav_data = Storage(
            nav_data = nav_data(
                add=links.add_point,
                loc=links.place,
                hom=links.home,
                sea=None,
                inf=links.info,
            ),
        )


        context.page_nav_data = page_nav_data

        get_page('search', context)
예제 #4
0
    def GET(self, topic_id):
        topics, topic = model.t_helper(topic_id)

        webinput = web.input()

        context = Storage(
            title=_(self.title),
            widgetizer_link=pc_links(self.widgetizer_link, topic_id),
            help_link=pc_links('guide', 'help_' + self.widget_link),
        )
        form = self.get_form(topic=topic)

        if not webinput.has_key("from_widget") or not form.validates():
            get_page("widgetize", context, topic, form)
        else:
            #d = Storage()
            #for k in form.d:
            #    if form.d[k]:
            #        d[k] = form.d[k]
            widget_link = widget_links(self.widget_link, topic.id, **form.d)
            result = Storage(
                link=widget_link,
                link_len=len(widget_link),
                height=form.d.height,
                width=form.d.width,
            )
            result.id = form.d.get("id", "")
            get_page("widgetize", context, topic, form, result=result)
예제 #5
0
    def GET(self):

        i = web.input(topic_hint=None)

        user = get_user()
        if user is None:
            Login().GET(webinput=Storage(come_back=links.add_point))
            return

        user_loc = user_location()
        if not user_loc[0]:
            MobileMap().GET()
            return


        context = Storage(
            title=_("List of points"),
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",                 
            ), 
        )

        page_nav_data = Storage(
            nav_data = nav_data(
                add=None,
                loc=links.place,
                hom=links.home,
                sea=links.search,
                inf=links.info,
            ),
        )

        context.page_nav_data = page_nav_data

        topics_subs = model.Projects(
            by_user_role=(user, "subscribed"))

        topics_highlighted = model.Projects(
            tags=model.Tags("official:highlighted"))

        topics_subs.add(topics_highlighted)

        topics_subs.annotate_by_profiles()
        topics_subs.filter_by_func(acl.authorize.add_point)

        topics_subs.sort_by_title()

        get_page('add_point', context, topics_subs)
예제 #6
0
    def POST(self, webinput=None):
        i = webinput or web.input()
        user, msg = autologin(i)

        context = Storage()

        if not user:
            get_page('login', context, come_back=i.get('come_back', ''))
            return
        if user.username:
            if "come_back" in i:
                web.seeother(i.come_back)
            else:
                web.seeother(links.map)
            return
예제 #7
0
    def POST(self, webinput=None):
        i = webinput or web.input()
        user, msg = autologin(i)

        context = Storage()

        if not user:
            get_page('login', context, come_back=i.get('come_back', ''))
            return
        if user.username:
            if "come_back" in i:
                web.seeother(i.come_back)
            else:
                web.seeother(links.map)
            return
예제 #8
0
    def GET(self):

        i = web.input(topic_hint=None)

        user = get_user()
        if user is None:
            Login().GET(webinput=Storage(come_back=links.add_point))
            return

        user_loc = user_location()
        if not user_loc[0]:
            MobileMap().GET()
            return

        context = Storage(
            title=_("List of points"),
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",
            ),
        )

        page_nav_data = Storage(nav_data=nav_data(
            add=None,
            loc=links.place,
            hom=links.home,
            sea=links.search,
            inf=links.info,
        ), )

        context.page_nav_data = page_nav_data

        topics_subs = model.Projects(by_user_role=(user, "subscribed"))

        topics_highlighted = model.Projects(
            tags=model.Tags("official:highlighted"))

        topics_subs.add(topics_highlighted)

        topics_subs.annotate_by_profiles()
        topics_subs.filter_by_func(acl.authorize.add_point)

        topics_subs.sort_by_title()

        get_page('add_point', context, topics_subs)
예제 #9
0
    def GET(self, webinput=None):
        i = webinput or web.input(t_id=None, p_id=None, search="", topic_id=None)

        topics, topic, points, point = model.t_p_helper(i.t_id, i.p_id)
        if not topics:
            print "ERROR"  #!!! should not occur often
            return

        user_lat, user_lon = user_location()
        if user_lat:
            points.annotate_by_distance(user_lat, user_lon)

        context = Storage(
            title=_("Point: details"),
            search=i.get("search", ""),      # for point page
            topic_id=i.topic_id,  # to know where to return to
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",                 
            ), 
            map_context=Storage(
                zoom=config.mobile_point_zoom + config.getmap_zoomshift, 
                map_width=config.mobile_map_width,
                map_height=config.mobile_map_height,
            ),
        )

        page_nav_data = Storage(
            nav_data = nav_data(
                add=links.add_point,
                loc=links.place,
                hom=links.point_list,
                sea=links.search,
                inf=links.info,
            ),
        )


        context.page_nav_data = page_nav_data

        get_page('point', context, topic, point)
예제 #10
0
    def GET(self, webinput=None):
        i = webinput or web.input(
            t_id=None, p_id=None, search="", topic_id=None)

        topics, topic, points, point = model.t_p_helper(i.t_id, i.p_id)
        if not topics:
            print "ERROR"  #!!! should not occur often
            return

        user_lat, user_lon = user_location()
        if user_lat:
            points.annotate_by_distance(user_lat, user_lon)

        context = Storage(
            title=_("Point: details"),
            search=i.get("search", ""),  # for point page
            topic_id=i.topic_id,  # to know where to return to
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",
            ),
            map_context=Storage(
                zoom=config.mobile_point_zoom + config.getmap_zoomshift,
                map_width=config.mobile_map_width,
                map_height=config.mobile_map_height,
            ),
        )

        page_nav_data = Storage(nav_data=nav_data(
            add=links.add_point,
            loc=links.place,
            hom=links.point_list,
            sea=links.search,
            inf=links.info,
        ), )

        context.page_nav_data = page_nav_data

        get_page('point', context, topic, point)
예제 #11
0
    def GET(self):
        context = Storage(
            title=_("List of points"),
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",
            ),
        )

        page_nav_data = Storage(nav_data=nav_data(
            add=links.add_point,
            loc=links.place,
            hom=links.home,
            sea=None,
            inf=links.info,
        ), )

        context.page_nav_data = page_nav_data

        get_page('search', context)
예제 #12
0
    def GET(self):
        context = Storage(
            title=_("List of points"),
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",
            ),
        )

        page_nav_data = Storage(nav_data=nav_data(
            add=links.add_point,
            loc=links.place,
            hom=links.home,
            sea=links.search,
            inf=None,
        ), )

        context.page_nav_data = page_nav_data
        context.about = model.doc_helper(context, "about", i18n.getLanguage())

        get_page('info', context)
예제 #13
0
    def GET(self, webinput=None):
        i = webinput or web.input(
            lat=None,
            lon=None,
            zoom=None,
            gps=None,
            address=None,
        )

        if i.get("gps", ""):
            i.zoom = float(i.zoom or
                           (config.mobile_gps_zoom + config.getmap_zoomshift))
        else:
            i.zoom = float(i.zoom
                           or (config.mobile_zoom + config.getmap_zoomshift))

        user = get_user()

        if user is None:
            user1, msg = autologin(i)
            if user1 is not None:
                user = user1

        location = None

        user_lat, user_lon = user_location()

        if user_lat:
            location_hint = \
                Storage(lat=float(user_lat),
                        lon=float(user_lon),
                        id=1,
                     )
        else:
            location_hint = \
                Storage(lat=float(config.center_lat),
                        lon=float(config.center_lon),
                        id=1,
                     )

        address_lookup = ""
        if i.get("address", ""):
            location = Storage(id=0,
                               zoom=float(config.mobile_zoom) +
                               config.getmap_zoomshift)
            metadata = {
                'hint_lat': location_hint.lat,
                'hint_lon': location_hint.lon,
            }
            location.update(
                model.geocoding_helper(i.address,
                                       onfail=('', ''),
                                       metadata=metadata))
            if not location.lat:
                location = None
                address_lookup = "failed"
            else:
                i.zoom = location.get(
                    "zoom",
                    float(config.mobile_zoom) + config.getmap_zoomshift)
                address_lookup = "success"
        if not location and i.lat and i.lon:
            location = \
                Storage(lat=float(i.lat.replace(",", ".")),
                        lon=float(i.lon.replace(",", ".")),
                        id=0,
                         )

        if "forget" in i:
            session.remove_info(dict(lat=None, lon=None, zoom=None))
            web.seeother(links.map)
            return
        elif "submit" in i and location:
            # set location
            session.update_info(
                dict(lat=float(location.lat or 0),
                     lon=float(location.lon or 0),
                     zoom=int(i.zoom) - config.getmap_zoomshift))

            web.seeother(links.point_list)
            return

        if not location:
            location = location_hint

        model.encode_coordinates(location)

        if config.getmap_custom_wms == "wms":
            map_context = mobile_map.MapContextHybrid(
                lat=location.lat,
                lon=location.lon,
                zoom=int(float(i.zoom)),
                links=links,
                map_width=config.mobile_map_width,
                map_height=config.mobile_map_height,
            )
        else:
            map_context = mobile_map.MapContextHybridOSM(
                lat=location.lat,
                lon=location.lon,
                zoom=int(float(i.zoom)),
                links=links,
                map_width=config.mobile_map_width,
                map_height=config.mobile_map_height,
            )

        map_context.tile_id = "%(lat)s,%(lon)s,%(zoom)s,%(map_width)s,%(map_height)s" % map_context

        context = Storage(
            title=_("User location"),
            address=i.get("address", ""),
            address_lookup=address_lookup,
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",
            ),
            map_context=map_context,
        )
        if "gps" in i:
            context.gps = i.gps

        page_nav_data = Storage(nav_data=nav_data(
            add=links.add_point,
            loc=None,
            hom=links.home,
            sea=links.search,
            inf=links.info,
        ), )

        context.page_nav_data = page_nav_data

        get_page('map', context, location)
예제 #14
0
    def GET(self):
        user = get_user()

        i = web.input(page="1",
                      order="",
                      lat="",
                      lon="",
                      search_nearby="",
                      topic_id="",
                      search="",
                      search_tags="",
                      mode="list")
        page = int(i.page)

        if i.topic_id:
            topics, topic = model.t_helper(i.topic_id)
        else:
            topic = None

        user_lat, user_lon = user_location()
        if not i.search and not i.search_nearby:
            # in absense of search terms, search nearby
            if user_lat:
                i.search_nearby = "1"
                i.lat, i.lon = float(user_lat), float(user_lon)

        if not topic:
            i.setdefault("nearby_radius", config.nearby_radius)
        else:
            i.nearby_radius = None

        points = model.search_helper(i)

        total_num_of_pages = points.num_of_pages(length=config.points_per_page)
        tags = model.tags_helper()

        model.order_helper(points, i.order)

        if i.mode != "map":  # map shows all points, not just one page
            points.limit_by_page(page, length=config.points_per_page)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_projects()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)
        if user_lat:
            points.annotate_by_distance(user_lat, user_lon)

        context = Storage(
            title=_("List of points"),
            nearby_radius=i.nearby_radius,
            search=i.search,
            search_nearby=i.search_nearby,
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",
            ),
        )

        page_nav_data = Storage(nav_data=nav_data(
            add=links.add_point,
            loc=links.place,
            hom=None,
            sea=links.search,
            inf=links.info,
        ), )

        context.page_nav_data = page_nav_data

        topics_set = set()
        topics_points = []
        topics_dict = {}
        for p in points:
            for t in p.projects:
                if t.id not in topics_set:
                    topics_set.add(t.id)
                    if topic is None or topic.id != t.id:
                        # do not show topic twice
                        topics_points.append(t)
                    topics_dict[t.id] = t
                    t.points = [p]
                else:
                    topics_dict[t.id].points.append(p)

        if topic is not None:
            if topic.id not in topics_set:
                points = []
            else:
                points = topics_dict[topic.id].points

        get_page('point_list', context, points, topics_points, topic)
예제 #15
0
    def GET(self, webinput=None):
        i = webinput or web.input(lat=None,
                      lon=None,
                      zoom=None,
                      gps=None,
                      address=None,
                      )

        if i.get("gps", ""):
            i.zoom = float(i.zoom or (config.mobile_gps_zoom + config.getmap_zoomshift))
        else:
            i.zoom = float(i.zoom or (config.mobile_zoom + config.getmap_zoomshift))

        user = get_user()

        if user is None:
            user1, msg = autologin(i)
            if user1 is not None:
                user = user1

        location = None

        user_lat, user_lon = user_location()

        if user_lat:
            location_hint = \
                Storage(lat=float(user_lat),
                        lon=float(user_lon),
                        id=1,
                     )
        else:
            location_hint = \
                Storage(lat=float(config.center_lat),
                        lon=float(config.center_lon),
                        id=1,
                     )


        address_lookup = ""
        if i.get("address", ""):
            location = Storage(id=0, zoom=float(config.mobile_zoom)+config.getmap_zoomshift)
            metadata = {'hint_lat': location_hint.lat,
                        'hint_lon': location_hint.lon,}
            location.update(
                model.geocoding_helper(i.address, 
                    onfail=('', ''), 
                    metadata=metadata)
            )
            if not location.lat:
                location = None
                address_lookup = "failed"
            else:
                i.zoom = location.get("zoom", float(config.mobile_zoom)+config.getmap_zoomshift)
                address_lookup = "success"
        if not location and i.lat and i.lon:
            location = \
                Storage(lat=float(i.lat.replace(",", ".")),
                        lon=float(i.lon.replace(",", ".")),
                        id=0,
                         )

        if "forget" in i:
            session.remove_info(dict(lat=None, 
                                lon=None,
                                zoom=None))
            web.seeother(links.map)
            return
        elif "submit" in i and location:
            # set location
            session.update_info(dict(lat=float(location.lat or 0), 
                                lon=float(location.lon or 0),
                                zoom=int(i.zoom) - config.getmap_zoomshift))

            web.seeother(links.point_list)
            return

        if not location:
            location = location_hint

        model.encode_coordinates(location)

        if config.getmap_custom_wms == "wms":
            map_context = mobile_map.MapContextHybrid(
                    lat=location.lat,
                    lon=location.lon,
                    zoom=int(float(i.zoom)),
                    links=links,
                    map_width=config.mobile_map_width,
                    map_height=config.mobile_map_height,
            )
        else:
            map_context = mobile_map.MapContextHybridOSM(
                    lat=location.lat,
                    lon=location.lon,
                    zoom=int(float(i.zoom)),
                    links=links,
                    map_width=config.mobile_map_width,
                    map_height=config.mobile_map_height,
            )

        map_context.tile_id = "%(lat)s,%(lon)s,%(zoom)s,%(map_width)s,%(map_height)s" % map_context

        context = Storage(
            title=_("User location"),
            address=i.get("address", ""),
            address_lookup=address_lookup,
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",                 
            ),
            map_context=map_context,
        )
        if "gps" in i:
            context.gps = i.gps

        page_nav_data = Storage(
            nav_data = nav_data(
                add=links.add_point,
                loc=None,
                hom=links.home,
                sea=links.search,
                inf=links.info,
            ),
        )


        context.page_nav_data = page_nav_data

        get_page('map', context, location)
예제 #16
0
    def GET(self):
        user = get_user()

        i = web.input(page="1", order="", 
                lat="", lon="", search_nearby="", topic_id="",
                search="", search_tags="", mode="list")
        page = int(i.page)

        if i.topic_id:
            topics, topic = model.t_helper(i.topic_id)
        else:
            topic = None

        user_lat, user_lon = user_location()
        if not i.search and not i.search_nearby:
            # in absense of search terms, search nearby
            if user_lat:
                i.search_nearby = "1"
                i.lat, i.lon = float(user_lat), float(user_lon)

        if not topic:
            i.setdefault("nearby_radius", config.nearby_radius)
        else:
            i.nearby_radius = None

        points = model.search_helper(i)

        total_num_of_pages = points.num_of_pages(length=config.points_per_page)
        tags = model.tags_helper()

        model.order_helper(points, i.order)

        if i.mode != "map":  # map shows all points, not just one page
            points.limit_by_page(page, length=config.points_per_page)
        points.annotate_by_comments()
        points.annotate_by_tags()
        points.annotate_by_projects()
        points.annotate_by_profiles(default=DEFAULT_POINT_PROFILE)
        if user_lat:
            points.annotate_by_distance(user_lat, user_lon)

        context = Storage(
            title=_("List of points"),
            nearby_radius=i.nearby_radius,
            search=i.search,
            search_nearby=i.search_nearby,
            status=Storage(
                add="add",
                loc=location_indicator(),  # !!! define better later
                hom="home",
                sea="search",
                inf="info",                 
            ), 
        )

        page_nav_data = Storage(
            nav_data = nav_data(
                add=links.add_point,
                loc=links.place,
                hom=None,
                sea=links.search,
                inf=links.info,
            ),
        )


        context.page_nav_data = page_nav_data

        topics_set = set()
        topics_points = []
        topics_dict = {}
        for p in points:
            for t in p.projects:
                if t.id not in topics_set:
                    topics_set.add(t.id)
                    if topic is None or topic.id != t.id:
                        # do not show topic twice
                        topics_points.append(t)
                    topics_dict[t.id] = t
                    t.points = [p]
                else:
                    topics_dict[t.id].points.append(p)

        if topic is not None:
            if topic.id not in topics_set:
                points = []
            else:
                points = topics_dict[topic.id].points

        get_page('point_list', context, points, topics_points, topic)