Compare commits
No commits in common. "11684b6fd7d1cc8d501070ef84899ae93f22ff94" and "a21b0ef7bd7189262b26c1f5b981e2f348c2bbaf" have entirely different histories.
11684b6fd7
...
a21b0ef7bd
|
@ -6,7 +6,6 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
|
||||
import collections
|
||||
import logging
|
||||
import os
|
||||
|
||||
import flatisfy.filters
|
||||
from flatisfy import database
|
||||
|
@ -204,14 +203,6 @@ def import_and_filter(config, load_from_db=False):
|
|||
if config["send_email"]:
|
||||
email.send_notification(config, new_flats)
|
||||
|
||||
# Touch a file to indicate last update timestamp
|
||||
ts_file = os.path.join(
|
||||
config["data_directory"],
|
||||
"timestamp"
|
||||
)
|
||||
with open(ts_file, 'w'):
|
||||
os.utime(ts_file, None)
|
||||
|
||||
LOGGER.info("Done!")
|
||||
|
||||
|
||||
|
|
|
@ -101,14 +101,12 @@ def get_app(config):
|
|||
app.route("/api/v1/ics/visits.ics", ["GET", "OPTIONS"],
|
||||
api_routes.ics_feed_v1)
|
||||
|
||||
app.route("/api/v1/search", ["POST", "OPTIONS"], api_routes.search_v1)
|
||||
app.route("/api/v1/search", "POST", api_routes.search_v1)
|
||||
|
||||
app.route("/api/v1/opendata", ["GET", "OPTIONS"], api_routes.opendata_index_v1)
|
||||
app.route("/api/v1/opendata/postal_codes", ["GET", "OPTIONS"],
|
||||
app.route("/api/v1/opendata", "GET", api_routes.opendata_index_v1)
|
||||
app.route("/api/v1/opendata/postal_codes", "GET",
|
||||
api_routes.opendata_postal_codes_v1)
|
||||
|
||||
app.route("/api/v1/metadata", ["GET", "OPTIONS"], api_routes.metadata_v1)
|
||||
|
||||
# Index
|
||||
app.route("/", "GET", lambda: _serve_static_file("index.html"))
|
||||
|
||||
|
|
|
@ -161,10 +161,3 @@ export const doSearch = function (query, callback) {
|
|||
console.error('Unable to perform search: ' + ex)
|
||||
})
|
||||
}
|
||||
|
||||
export const getMetadata = function (callback) {
|
||||
fetch('/api/v1/metadata', { credentials: 'same-origin' })
|
||||
.then(response => response.json())
|
||||
.then(json => callback(json.data))
|
||||
.catch(ex => console.error('Unable to fetch application metadata: ' + ex))
|
||||
}
|
||||
|
|
|
@ -56,13 +56,13 @@
|
|||
<script>
|
||||
import 'font-awesome-webpack'
|
||||
|
||||
import FlatsTableLine from './flatstableline.vue'
|
||||
import FlatsTableLine from './flatstableline.vue';
|
||||
|
||||
import { capitalize } from '../tools'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FlatsTableLine
|
||||
FlatsTableLine,
|
||||
},
|
||||
|
||||
data () {
|
||||
|
@ -129,7 +129,7 @@ export default {
|
|||
this.sortBy = field
|
||||
}
|
||||
},
|
||||
capitalize: capitalize
|
||||
capitalize: capitalize,
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -66,33 +66,33 @@ export default {
|
|||
props: {
|
||||
flat: Object,
|
||||
showNotationColumn: Boolean,
|
||||
showNotes: Boolean
|
||||
showNotes: Boolean,
|
||||
},
|
||||
|
||||
computed: {
|
||||
capitalizedStatus () {
|
||||
return capitalize(this.$t('status.followed'))
|
||||
capitalizedStatus() {
|
||||
return capitalize(this.$t('status.followed'));
|
||||
},
|
||||
photo () {
|
||||
photo() {
|
||||
if (this.flat.photos && this.flat.photos.length > 0) {
|
||||
if (this.flat.photos[0].local) {
|
||||
return `/data/img/${this.flat.photos[0].local}`
|
||||
return `/data/img/${this.flat.photos[0].local}`;
|
||||
}
|
||||
return this.flat.photos[0].url
|
||||
return this.flat.photos[0].url;
|
||||
}
|
||||
return null
|
||||
return null;
|
||||
},
|
||||
notationRange() {
|
||||
return range(this.flat.notation);
|
||||
},
|
||||
notationRange () {
|
||||
return range(this.flat.notation)
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
updateFlatStatus (id, status) {
|
||||
this.$store.dispatch('updateFlatStatus', { flatId: id, newStatus: status })
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -28,14 +28,14 @@ export default {
|
|||
},
|
||||
|
||||
computed: {
|
||||
photosURLOrLocal () {
|
||||
photosURLOrLocal() {
|
||||
return this.photos.map(photo => {
|
||||
if (photo.local) {
|
||||
return `/data/img/${photo.local}`
|
||||
return `/data/img/${photo.local}`;
|
||||
}
|
||||
return photo.url
|
||||
})
|
||||
}
|
||||
return photo.url;
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
created () {
|
||||
|
|
|
@ -19,7 +19,6 @@ export default {
|
|||
},
|
||||
home: {
|
||||
'new_available_flats': 'New available flats',
|
||||
'Last_update': 'Last update:',
|
||||
'show_expired_flats': 'Show expired flats'
|
||||
},
|
||||
flatListing: {
|
||||
|
@ -42,7 +41,7 @@ export default {
|
|||
'utilities_included': '(utilities included)',
|
||||
'utilities_excluded': '(utilities excluded)',
|
||||
'Description': 'Description',
|
||||
'First_posted': 'First posted',
|
||||
'First_posted' : 'First posted',
|
||||
'Details': 'Details',
|
||||
'Metadata': 'Metadata',
|
||||
'postal_code': 'Postal code',
|
||||
|
|
|
@ -19,7 +19,6 @@ export default {
|
|||
},
|
||||
home: {
|
||||
'new_available_flats': 'Nouveaux appartements disponibles',
|
||||
'Last_update': 'Dernière mise à jour :',
|
||||
'show_expired_flats': 'Montrer les annonces expirées'
|
||||
},
|
||||
flatListing: {
|
||||
|
|
|
@ -50,11 +50,5 @@ export default {
|
|||
api.doSearch(query, flats => {
|
||||
commit(types.REPLACE_FLATS, { flats })
|
||||
})
|
||||
},
|
||||
getMetadata ({ commit }) {
|
||||
commit(types.IS_LOADING)
|
||||
api.getMetadata(metadata => {
|
||||
commit(types.RECEIVE_METADATA, { metadata })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,5 @@ export default {
|
|||
|
||||
timeToPlaces: (state, getters) => (constraintName) => {
|
||||
return state.timeToPlaces[constraintName]
|
||||
},
|
||||
|
||||
metadata: state => state.metadata
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,5 +5,4 @@ export const UPDATE_FLAT_NOTES = 'UPDATE_FLAT_NOTES'
|
|||
export const UPDATE_FLAT_NOTATION = 'UPDATE_FLAT_NOTATION'
|
||||
export const UPDATE_FLAT_VISIT_DATE = 'UPDATE_FLAT_VISIT_DATE'
|
||||
export const RECEIVE_TIME_TO_PLACES = 'RECEIVE_TIME_TO_PLACES'
|
||||
export const RECEIVE_METADATA = 'RECEIVE_METADATA'
|
||||
export const IS_LOADING = 'IS_LOADING'
|
||||
|
|
|
@ -5,7 +5,6 @@ import * as types from './mutations-types'
|
|||
export const state = {
|
||||
flats: [],
|
||||
timeToPlaces: [],
|
||||
metadata: [],
|
||||
loading: 0
|
||||
}
|
||||
|
||||
|
@ -59,10 +58,6 @@ export const mutations = {
|
|||
state.timeToPlaces = timeToPlaces
|
||||
state.loading -= 1
|
||||
},
|
||||
[types.RECEIVE_METADATA] (state, { metadata }) {
|
||||
state.metadata = metadata
|
||||
state.loading -= 1
|
||||
},
|
||||
[types.IS_LOADING] (state) {
|
||||
state.loading += 1
|
||||
}
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
|
||||
<h2>
|
||||
{{ $t("home.new_available_flats") }}
|
||||
<template v-if="lastUpdate">
|
||||
<label class="show-last-update">
|
||||
{{ $t("home.Last_update") }} {{ lastUpdate.fromNow() }}
|
||||
</label>
|
||||
</template>
|
||||
<label class="show-expired-flats-label">
|
||||
<input type="checkbox" class="show-expired-flats-checkbox" v-model="showExpiredFlats" />
|
||||
{{ $t("home.show_expired_flats") }}
|
||||
|
@ -38,7 +33,6 @@
|
|||
<script>
|
||||
import FlatsMap from '../components/flatsmap.vue'
|
||||
import FlatsTable from '../components/flatstable.vue'
|
||||
import moment from 'moment'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
|
@ -53,14 +47,12 @@ export default {
|
|||
this.$store.dispatch('getAllFlats')
|
||||
// Fetch time to places when the component is created
|
||||
this.$store.dispatch('getAllTimeToPlaces')
|
||||
// Fetch application metadata when the component is created
|
||||
this.$store.dispatch('getMetadata')
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
showExpiredFlats: false
|
||||
}
|
||||
showExpiredFlats: false,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
|
@ -79,14 +71,6 @@ export default {
|
|||
timeToPlaces () {
|
||||
return this.$store.getters.allTimeToPlaces
|
||||
},
|
||||
lastUpdate () {
|
||||
var metadata = this.$store.getters.metadata
|
||||
var lastUpdateDate = moment.unix(metadata['last_update'])
|
||||
if (!lastUpdateDate.isValid()) {
|
||||
lastUpdateDate = 0
|
||||
}
|
||||
return lastUpdateDate
|
||||
},
|
||||
isLoading () {
|
||||
return this.$store.getters.isLoading
|
||||
}
|
||||
|
@ -104,9 +88,4 @@ h2 {
|
|||
font-weight: initial;
|
||||
font-size: initial;
|
||||
}
|
||||
|
||||
.show-last-update {
|
||||
font-weight: initial;
|
||||
font-size: initial;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -10,7 +10,6 @@ import datetime
|
|||
import itertools
|
||||
import json
|
||||
import re
|
||||
import os
|
||||
|
||||
import bottle
|
||||
import vobject
|
||||
|
@ -147,8 +146,7 @@ def index_v1():
|
|||
"flat": "/api/v1/flat/:id",
|
||||
"search": "/api/v1/search",
|
||||
"ics": "/api/v1/ics/visits.ics",
|
||||
"time_to_places": "/api/v1/time_to_places",
|
||||
"metadata": "/api/v1/metadata"
|
||||
"time_to_places": "/api/v1/time_to_places"
|
||||
}
|
||||
|
||||
|
||||
|
@ -439,10 +437,6 @@ def opendata_index_v1():
|
|||
|
||||
GET /api/v1/opendata
|
||||
"""
|
||||
if bottle.request.method == 'OPTIONS':
|
||||
# CORS
|
||||
return {}
|
||||
|
||||
return {
|
||||
"postal_codes": "/api/v1/opendata/postal_codes"
|
||||
}
|
||||
|
@ -505,36 +499,3 @@ def opendata_postal_codes_v1(db):
|
|||
}
|
||||
except Exception as exc: # pylint: disable= broad-except
|
||||
return JSONError(500, str(exc))
|
||||
|
||||
def metadata_v1(config):
|
||||
"""
|
||||
API v1 metadata of the application.
|
||||
|
||||
Example::
|
||||
|
||||
GET /api/v1/metadata
|
||||
|
||||
:return: The application metadata.
|
||||
"""
|
||||
if bottle.request.method == 'OPTIONS':
|
||||
# CORS
|
||||
return {}
|
||||
|
||||
try:
|
||||
last_update = None
|
||||
try:
|
||||
ts_file = os.path.join(
|
||||
config['data_directory'],
|
||||
'timestamp'
|
||||
)
|
||||
last_update = os.path.getmtime(ts_file)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
return {
|
||||
'data': {
|
||||
'last_update': last_update
|
||||
}
|
||||
}
|
||||
except Exception as exc: # pylint: disable= broad-except
|
||||
return JSONError(500, str(exc))
|
||||
|
|
Loading…
Reference in New Issue