Various UI fixes

* Fix status on details page
* Fix follow button on details page
* Replace back button by a link on the flat status
* Fix leaflet markers position, close #24
* Fix Leaflet icons
* Add unfollow link on followed posts
This commit is contained in:
Lucas Verney 2017-04-28 11:35:45 +02:00
parent bd3e599d12
commit 2af742b764
5 changed files with 101 additions and 18 deletions

View File

@ -183,8 +183,6 @@ def main():
cmds.import_and_filter(config, load_from_db=True) cmds.import_and_filter(config, load_from_db=True)
# Import command # Import command
elif args.cmd == "import": elif args.cmd == "import":
# TODO: Do not fetch details for already imported flats / use the last
# timestamp
cmds.import_and_filter(config, load_from_db=False) cmds.import_and_filter(config, load_from_db=False)
# Purge command # Purge command
elif args.cmd == "purge": elif args.cmd == "purge":

View File

@ -107,3 +107,76 @@ def detect(flats_list, key="id", merge=True, should_intersect=False):
should_intersect=False) should_intersect=False)
return unique_flats_list, duplicate_flats return unique_flats_list, duplicate_flats
def deep_detect(flats_list):
"""
TODO
"""
for i, flat1 in enumerate(flats_list):
for j, flat2 in enumerate(flats_list):
if i < j:
continue
n_common_items = 0
try:
# They should have the same area, up to one unit
assert abs(flat1["area"] - flat2["area"]) < 1
n_common_items += 1
# They should be at the same price, up to one unit
assert abs(flat1["cost"] - flat2["cost"]) < 1
n_common_items += 1
# They should have the same number of bedrooms if this was
# fetched for both
if flat1["bedrooms"] and flat2["bedrooms"]:
assert flat1["bedrooms"] == flat2["bedrooms"]
n_common_items += 1
# They should have the same utilities (included or excluded for
# both of them), if this was fetched for both
if flat1["utilities"] and flat2["utilities"]:
assert flat1["utilities"] == flat2["utilities"]
n_common_items += 1
# They should have the same number of rooms if it was fetched
# for both of them
if flat1["rooms"] and flat2["rooms"]:
assert flat1["rooms"] == flat2["rooms"]
n_common_items += 1
# They should have the same postal code, if available
if (
flat1["flatisfy"].get("postal_code", None) and
flat2["flatisfy"].get("postal_code", None)
):
assert (
flat1["flatisfy"]["postal_code"] ==
flat2["flatisfy"]["postal_code"]
)
n_common_items += 1
# They should have the same phone number if it was fetched for
# both
if flat1["phone"] and flat2["phone"]:
homogeneize_phone_number = lambda number: (
number.replace(".", "").replace(" ", "")
)
pass # TODO: Homogeneize phone numbers
# TODO: Compare texts (one is included in another? fuzzymatch?)
except AssertionError:
# Skip and consider as not duplicates whenever the conditions
# are not met
continue
except TypeError:
# TypeError occurs when an area or a cost is None, which should
# not be considered as duplicates
continue
# TODO: Check the number of common items
# TODO: Merge flats
# TODO: Compare photos

View File

@ -21,10 +21,16 @@
<script> <script>
import L from 'leaflet' import L from 'leaflet'
// Fix for a bug in Leaflet default icon
// see https://github.com/PaulLeCam/react-leaflet/issues/255#issuecomment-261904061
delete L.Icon.Default.prototype._getIconUrl;
L.Icon.Default.mergeOptions({
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
iconUrl: require('leaflet/dist/images/marker-icon.png'),
shadowUrl: require('leaflet/dist/images/marker-shadow.png'),
});
import 'leaflet/dist/leaflet.css' import 'leaflet/dist/leaflet.css'
import markerUrl from 'leaflet/dist/images/marker-icon.png'
import marker2XUrl from 'leaflet/dist/images/marker-icon.png'
import shadowUrl from 'leaflet/dist/images/marker-icon.png'
require('leaflet.icon.glyph') require('leaflet.icon.glyph')
@ -51,11 +57,7 @@ export default {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}, },
icons: { icons: {
flat: L.icon({ flat: new L.Icon.Default(),
iconUrl: markerUrl,
iconRetinaUrl: marker2XUrl,
shadowUrl: shadowUrl
}),
place: L.icon.glyph({ place: L.icon.glyph({
prefix: 'fa', prefix: 'fa',
glyph: 'clock-o' glyph: 'clock-o'

View File

@ -8,6 +8,7 @@ export default {
'Restore': 'Restore', 'Restore': 'Restore',
'External_link': 'External link', 'External_link': 'External link',
'Follow': 'Follow', 'Follow': 'Follow',
'Unfollow': 'Unfollow',
'Close': 'Close', 'Close': 'Close',
'sortUp': 'Sort in ascending order', 'sortUp': 'Sort in ascending order',
'sortDown': 'Sort in descending order' 'sortDown': 'Sort in descending order'

View File

@ -3,10 +3,11 @@
<div class="grid" v-if="flat && timeToPlaces"> <div class="grid" v-if="flat && timeToPlaces">
<div class="left-panel"> <div class="left-panel">
<h2> <h2>
<router-link :to="'/' + flat.status"> (<!--
<i class="fa fa-arrow-left" aria-hidden="true"></i> --><router-link :to="{ name: 'status', params: { status: flat.status }}"><!--
</router-link> -->{{ flat.status ? capitalize($t("status." + flat.status)) : '' }}<!--
({{ flat.status ? capitalize(flat.status) : '' }}) {{ flat.title }} [{{ flat.id.split("@")[1] }}] --></router-link><!--
-->) {{ flat.title }} [{{ flat.id.split("@")[1] }}]
</h2> </h2>
<div class="grid"> <div class="grid">
<div class="left-panel"> <div class="left-panel">
@ -128,10 +129,18 @@
<ul> <ul>
<template v-if="flat.status !== 'user_deleted'"> <template v-if="flat.status !== 'user_deleted'">
<li> <li>
<button v-on:click="updateFlatStatus('follow')"> <template v-if="flat.status !== 'followed'">
<i class="fa fa-star" aria-hidden="true"></i> <button v-on:click="updateFlatStatus('followed')">
{{ $t("common.Follow") }} <i class="fa fa-star" aria-hidden="true"></i>
</button> {{ $t("common.Follow") }}
</button>
</template>
<template v-else>
<button v-on:click="updateFlatStatus('new')">
<i class="fa fa-star-o" aria-hidden="true"></i>
{{ $t("common.Unfollow") }}
</button>
</template>
</li> </li>
<li> <li>
<button v-on:click="updateFlatStatus('user_deleted')"> <button v-on:click="updateFlatStatus('user_deleted')">