DDD - Information Systems
TravelMatch
Detailed Design Document
Version 1.0
D.J. van den Brand (0772180)
S. He (0810831)
J.M.A.P. van Hoof (0778486)
G.C. Linders (0815449)
M.J.M. Muijsers (0805654)
G.H. Santegoeds (0890429)
L.D. Stooker (0819041)
J.W.J.H. Visser (0828234)
22nd June, 2015
Abstract
This document contains the Detailed Design Document for the TravelMatch application, which is
used to help people find their holiday destination. This application is developed in the Software
Engineering Project at Eindhoven University of Technology. This document complies with the ESA
software engineering standard [1].
TravelMatch
Detailed Design Document
Contents
Document Status Sheet
General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Document history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5
5
5
Document Change Records
General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
6
6
1 Introduction
1.1 Purpose . . . . . . . . . . .
1.2 Scope . . . . . . . . . . . .
1.3 Definitions and abbreviations
1.3.1 Definitions . . . . . .
1.3.2 Abbreviations . . . .
1.4 References . . . . . . . . . .
1.5 Overview . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
7
7
7
7
7
8
9
10
2 Standards and conventions
2.1 Design standards . . . . .
2.2 Documentation standards .
2.2.1 General . . . . . .
2.2.2 AngularJS-specific .
2.3 Naming conventions . . . .
2.3.1 Front end . . . . .
2.3.2 Back end . . . . .
2.4 Coding standards . . . . .
2.4.1 Front end . . . . .
2.4.2 Back end . . . . .
2.5 Software development tools
2.5.1 General . . . . . .
2.5.2 Front end . . . . .
2.5.3 Back end . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
11
11
11
11
12
12
12
13
13
13
14
14
14
14
14
3 Component descriptions
3.1 Front end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Back end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
15
17
4 Build procedure
4.1 Front end . . . . . . .
4.1.1 Prerequisites . .
4.1.2 Build process .
4.2 Back end . . . . . . . .
4.2.1 Prerequisites . .
4.2.2 Building server .
19
19
19
19
20
20
20
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
TravelMatch
Detailed Design Document
A Front end documentation
A.1 Documentation template . . .
A.2 app.about . . . . . . . . . . .
A.2.1 AboutCtrl . . . . . . .
A.2.2 AnalyticsService . . . .
A.3 app.config . . . . . . . . . . .
A.3.1 HttpInterceptor . . . .
A.3.2 BACK BUTTON . . .
A.3.3 BASE URL . . . . . .
A.3.4 DEBUG URL . . . . .
A.3.5 SHOW SWIPE DEBUG
A.3.6 STATE NAMES . . . .
A.3.7 USE DEBUG . . . . .
A.3.8 USE FRONT . . . . .
A.3.9 AuthService . . . . . .
A.4 app.debug . . . . . . . . . . .
A.4.1 DebugService . . . . .
A.5 app.details . . . . . . . . . . .
A.5.1 DetailCtrl . . . . . . .
A.5.2 VacationDetailsService
A.6 app.front . . . . . . . . . . . .
A.6.1 FrontCtrl . . . . . . . .
A.7 app.hotel.overview . . . . . . .
A.7.1 HotelOverviewCtrl . . .
A.7.2 HotelService . . . . . .
A.8 app.login . . . . . . . . . . . .
A.8.1 LoginCtrl . . . . . . . .
A.8.2 facebookButton . . . .
A.8.3 LoginService . . . . . .
A.9 app.module . . . . . . . . . .
A.10 app.navigation . . . . . . . . .
A.10.1 MainCtrl . . . . . . . .
A.10.2 tmHeader . . . . . . .
A.10.3 tmLoginTabs . . . . . .
A.10.4 tmMenu . . . . . . . .
A.10.5 tmMenuButton . . . .
A.11 app.registration . . . . . . . .
A.11.1 RegistrationCtrl . . . .
A.11.2 RegistrationService . .
A.12 app.swipe . . . . . . . . . . .
A.12.1 SwipeCtrl . . . . . . .
A.12.2 tmPhoto . . . . . . . .
A.12.3 ImageService . . . . . .
A.13 app.user.details . . . . . . . .
A.13.1 UserDetailCtrl . . . . .
A.13.2 UserDetailsService . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
21
21
21
21
21
22
22
23
23
24
24
24
24
24
24
25
25
26
26
27
32
32
32
32
34
37
37
38
38
39
39
39
40
41
42
43
43
43
43
45
45
47
49
51
51
52
B Back end documentation
B.1 Documentation template . .
B.2 affiliate . . . . . . . . . . . .
B.3 affiliate.affiliate parser . . . .
B.3.1 Parser . . . . . . . .
B.4 affiliate.models . . . . . . . .
B.4.1 AbstractParserModel
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
54
54
55
55
55
59
60
.
.
.
.
.
.
2
TravelMatch
B.5
B.6
B.7
B.8
B.9
B.10
B.11
B.12
B.13
B.14
B.15
B.16
B.17
B.18
B.4.2 AffiliateFeed . . . . . . . . . . .
B.4.3 AffiliateFeed.Meta . . . . . . . .
B.4.4 ArkeParserModel . . . . . . . .
B.4.5 Trip . . . . . . . . . . . . . . .
affiliate.serializer . . . . . . . . . . . . .
affiliate.tradetracker . . . . . . . . . . .
affiliate.tradetracker.arke parser . . . . .
B.7.1 ArkeParser . . . . . . . . . . . .
affiliate.views . . . . . . . . . . . . . .
ai . . . . . . . . . . . . . . . . . . . . .
ai.entropy . . . . . . . . . . . . . . . .
ai.models . . . . . . . . . . . . . . . . .
B.11.1 ImageBlacklistItem . . . . . . .
B.11.2 ImageBlacklistItem.Meta . . . .
B.11.3 ImageDimension . . . . . . . . .
B.11.4 ImageDimension.Meta . . . . . .
B.11.5 ImageTag . . . . . . . . . . . .
B.11.6 ImageTag.Meta . . . . . . . . .
B.11.7 Location . . . . . . . . . . . . .
B.11.8 LocationBlacklistItem . . . . . .
B.11.9 LocationBlacklistItem.Meta . . .
B.11.10LocationTag . . . . . . . . . . .
B.11.11LocationTag.Meta . . . . . . . .
B.11.12SwipeImage . . . . . . . . . . .
B.11.13Tag . . . . . . . . . . . . . . .
B.11.14Tag.Meta . . . . . . . . . . . .
B.11.15TravelDNA . . . . . . . . . . . .
B.11.16TravelDNA.Meta . . . . . . . .
B.11.17TripOffer . . . . . . . . . . . . .
B.11.18TripOffer.Meta . . . . . . . . .
B.11.19VacationTag . . . . . . . . . . .
B.11.20VacationTag.Meta . . . . . . . .
ai.recommender system . . . . . . . . .
ai.serializers . . . . . . . . . . . . . . .
B.13.1 LocationSerializer . . . . . . . .
B.13.2 Meta . . . . . . . . . . . . . . .
B.13.3 TripOfferSerializer . . . . . . . .
ai.views . . . . . . . . . . . . . . . . .
appusers . . . . . . . . . . . . . . . . .
appusers.authentication . . . . . . . . .
B.16.1 MyJSONWebTokenAuthenticator
appusers.mailgun . . . . . . . . . . . .
appusers.models . . . . . . . . . . . . .
B.18.1 AppUser . . . . . . . . . . . . .
B.18.2 AppUser.Meta . . . . . . . . . .
B.18.3 FBAppUser . . . . . . . . . . .
B.18.4 GuestAppUser . . . . . . . . . .
B.18.5 MailAppUser . . . . . . . . . . .
B.18.6 PendingActivation . . . . . . . .
B.18.7 PendingActivation.Meta . . . . .
B.18.8 SavedLocation . . . . . . . . . .
B.18.9 SavedLocation.Meta . . . . . . .
B.18.10TripList . . . . . . . . . . . . .
B.18.11TripListEntry . . . . . . . . . .
Detailed Design Document
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
3
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
61
62
62
63
65
66
66
66
67
67
67
71
76
77
77
79
79
81
81
83
84
85
87
87
88
89
90
93
93
95
95
96
97
100
101
101
102
102
102
103
103
104
106
108
110
110
111
112
113
114
114
115
115
116
TravelMatch
B.18.12VacationDetail . . . . . . . . . .
B.18.13VacationDetail.Meta . . . . . .
B.19 appusers.serializers . . . . . . . . . . . .
B.19.1 FBUserSerializer . . . . . . . . .
B.19.2 GuestAccountSerializer . . . . .
B.19.3 MailUserSerializer . . . . . . . .
B.19.4 Meta . . . . . . . . . . . . . . .
B.19.5 UserSerializer . . . . . . . . . .
B.19.6 VacationDetailsSerializer . . . .
B.20 appusers.views . . . . . . . . . . . . . .
B.20.1 APIError . . . . . . . . . . . . .
B.20.2 APIRecommendation . . . . . .
B.20.3 APIUser . . . . . . . . . . . . .
B.20.4 APIUserAuth . . . . . . . . . .
B.20.5 APIUserHotel . . . . . . . . . .
B.20.6 APIUserLocation . . . . . . . .
B.20.7 APIUserLogin . . . . . . . . . .
B.20.8 APIUserMe . . . . . . . . . . .
B.20.9 APIUserMyLocation . . . . . . .
B.20.10APIUserMyLocationAll . . . . .
B.20.11APIUserMyLocationAllValues . .
B.20.12APIUserSwipe . . . . . . . . . .
B.20.13APIUserVacationDetails . . . . .
B.20.14APIUserVacationDetailsAllValues
B.20.15APIUserVacationDetailsLatest .
B.20.16JSONResponse . . . . . . . . .
Detailed Design Document
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
4
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
117
120
120
124
124
125
125
126
126
126
135
136
136
136
137
137
137
138
138
138
139
139
139
140
140
140
TravelMatch
Detailed Design Document
Document Status Sheet
General
Document title:
Document identifier:
Authors:
Document status:
Detailed Design Document
TravelMatch.Doc.DDD/1.0
D.J. van den Brand (0772180)
S. He
(0810831)
J.M.A.P. van Hoof
(0778486)
G.C. Linders
(0815449)
M.J.M. Muijsers
(0805654)
G.H. Santegoeds
(0890429)
L.D. Stooker
(0819041)
J.W.J.H. Visser
(0828234)
Final document
Document history
Version
0.1
Date
17-06-2015
1.0
19-06-2015
Author(s)
D.J. van den Brand, S. He,
J.M.A.P. van Hoof, G.C. Linders,
M.J.M. Muijsers
D.J. van den Brand, S. He, G.C.
Linders, M.J.M. Muijsers
5
Reason
Initial version.
Final version.
TravelMatch
Detailed Design Document
Document Change Records
General
Date:
Document title:
Document identifier:
22nd June, 2015
Detailed Design Document
TravelMatch.Doc.DDD/1.0
Changes
Section
Reason
6
TravelMatch
Detailed Design Document
Chapter 1
Introduction
1.1
Purpose
This Detailed Design Document (DDD) describes the implementation of the TravelMatch system on
the most detailed level. The implementation of all components of the TravelMatch system, as defined
in the Software Requirements Document[3] and Architecture Design Document[4], is described in this
document.
1.2
Scope
TravelMatch is an application designed for smartphones and tablets, conceived by iLysian B.V. and
developed by the TravelMatch development team. The purpose of the application is to assist users in
planning a vacation by showing them images from various destinations and hotels or other places to
stay. The application employs machine learning to build a profile of the user in order to suggest the
ideal trip.
1.3
Definitions and abbreviations
1.3.1
Definitions
Affiliate Network
A network that enables you to receive money from customer redirection [18]
Analytics Data
The log of analytics events that is recorded and stored on the database.
Android
A popular open-source operating system for embedded devices, including
smartphones and tablets, created by Google.
Angular JS
An open-source web application framework maintained by Google.
Cosine similarity
A measure of similarity between two vectors of an inner product space that
measures the cosine of the angle between them.
Destination advice
The city, and selection of hotels, that is advised to a user after performing
one or more interest analyses.
Destination attributes Each destination will have one or more destination attributes
or tags
with an associated numerical relative value, those attributes cover the same
preferences as the DNA attribute.
DNA attribute
or tags
These are the attributes that the client wants to use to compose the DNA
of. In the beginning 10 attributes are chosen and each image shall have a
relative numerical value on one or more of the attributes. Attributes can be
added or removed later for new and existing images and DNA.
Google Play Store
A public repository of free and paid apps for Android, managed by Google.
Guest user
An user that does not provide login details but still uses the TravelMatch
app.
Hotelstars rating
A hotel classification with common criteria and procedures in participating
countries to rate a hotel’s quality. See [21].
7
TravelMatch
Detailed Design Document
iLysian
Short for iLysian B.V., a software engineering company situated in Eindhoven, Netherlands. The client for the TravelMatch project.
Interest analysis
The action the user will do of judging the images.
iOS
A popular closed-source operating system for smartphones and tablets created by Apple.
iOS App Store
A public repository of free and paid apps for iOS, managed by Apple.
JWT
JSON Web Token: a compact URL-safe means of representing claims to be
transferred between two parties, and used in TravelMatch as authentication
token, since it is self-validating.
Relational database
management system
(RDBMS)
A database management system (a piece of computer software that interacts
with users, other applications and a database to capture and analyze data)
based on the relational model (commonly based on the relational database
model)
TCP/IP
A computer networking model and set of communication protocols used
on the internet and similar computer networks, including the Transmission
Control Protocol (TCP) and the Internet Protocol (IP)
Tinder
A popular dating application for smartphones and tablets featuring a swipe
based interface, where a swipe to the left indicates a dislike and a swipe to
the right indicates a like.
Travel DNA
A collection of information about vacation preferences of a specific user or,
more specifically, one vacation of that user. This information is stored on the
server in a table with values representing the respective gain per attribute
for each image the user has swiped.
TravelMatch
An application for smartphones and tablets that assists users in planning a
vacation. The subject of this project.
TravelMatch team
A team of Computer Science students at Eindhoven University of Technology
who will design and implement the TravelMatch application.
User
The user of the app.
Waverunner
Waverunner Search Service by Pyton Communication Services; a search service that provides vacation offers and prices of participating travel agencies.
1.3.2
ADD
ADT
AI
APK
App
CMS
DDD
DOM
ESA
HTTP
IDE
IPA
NPM
OS
SRD
TU/e
Abbreviations
Architecture Design Document
Abstract Data Type
Artificial Intelligence
Android Application Package
Application for smartphones and tablets
Content Management System
Detailed Design Document
Document Object Model
European Space Agency
Hypertext Transfer Protocol
Integrated Development Environment
iOS App Store Package
Node Package Manager
Operating System
Software Requirements Document
Eindhoven University of Technology
8
TravelMatch
UML
URD
1.4
Detailed Design Document
Unified Modeling Language
User Requirements Document
References
[1] ESA PSS-05-0 Issue 2, Software requirements and architecture engineering process, February 1991
[2] TravelMatch team. User Requirement Document. Version 1.2.1. 22 June 2015.
[3] TravelMatch team. Software Requirements Document. Version 1.0. 22 June 2015.
[4] TravelMatch team. Architectural Design Document. Version 1.0. 22 June 2015.
[5] TravelMatch team. Detailed Design Document. Version 1.0. 22 June 2015.
[6] TravelMatch team. Software User Manual. Version 1.0. 22 June 2015.
[7] TravelMatch team. Software Transfer Document. Version 1.0. 22 June 2015.
[8] TravelMatch team. Unit Test Plan. Version 1.0. 22 June 2015.
[9] TravelMatch team. Integration Test Plan. Version 1.0. 22 June 2015.
[10] TravelMatch team. Acceptance Test Plan. Version 1.0.2. 22 June 2015.
[11] TravelMatch team. Software Configuration Management Plan. Version 1.0. 22 June 2015.
[12] TravelMatch team. Software Project Management Plan. Version 1.0. 22 June 2015.
[13] TravelMatch team. Software Quality Assurance Plan. Version 1.0. 22 June 2015.
[14] TravelMatch team. Software Verification and Validation Plan. Version 1.0. 22 June 2015.
[15] Tom Preston-Werner. Semantic Versioning 2.0.0. Retrieved 6 May 2015. http://www.semver.
org/
[16] Coley Consulting. MoSCoW Prioritisation.
coleyconsulting.co.uk/moscow.htm
Retrieved
29
April
2015.
http://www.
[17] Tinder, Inc. Tinder. Retrieved 29 April 2015. http://www.gotinder.com/
[18] Organized Shopping, LLC. Affiliate Network. Marketing Terms. Retrieved 29 April 2015. http:
//www.marketingterms.com/dictionary/affiliate_network/
[19] Daiycon. About Daisycon. Retrieved 29 April 2015. http://www.daisycon.com/en/about_
daisycon/
[20] Drifty Co. Ionic: Advanced HTML5 Hybrid Mobile App Framework. Retrieved 30 April 2015.
http://ionicframework.com/
[21] Hotelstars Union. Classification criteria 2015-2020. Retrieved 1 May 2015. http://www.
hotelstars.eu/index.php?id=criteria
[22] Django. http://www.django-cms.org/en/
[23] Django administration module. The Django Django admin site. Retrieved 1 June 2015. https:
//docs.djangoproject.com/en/1.8/ref/contrib/admin/
[24] Django Software Foundation. The Web framework for perfectionists with deadlines — Django.
Retrieved 1 June 2015. https://www.djangoproject.com/
9
TravelMatch
Detailed Design Document
[25] Facebook User ID. User IDs and Friends. Retrieved 2 June 2015. https://developers.
facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
[26] ImageMagick. ImageMagick: Convert, Edit, Or Compose Bitmap Images. Retrieved 2 June 2015.
http://www.imagemagick.org/
[27] Google. AngularJS - Superheroic JavaScript MVW Framework. Retrieved 1 June 2015. https:
//angularjs.org
[28] Adobe Systems Inc. Phonegap: Home. Retrieved 1 June 2015. http://phonegap.com/
[29] Xamarin Inc. Mobile App Development & App Creation Software - Xamarin. Retrieved 1 June
2015. http://xamarin.com/
[30] Eric Raymond. The Jargon File. Version 4.4.7. Retrieved 17 June 2015. http://www.catb.org/
jargon/html/
[31] Python Software Foundation. Classes. The Python Tutorial. Retrieved 18 June 2015. https:
//docs.python.org/2/tutorial/classes.html
[32] Python Software Foundation. PEP 0008 – Style Guide for Python Code. 1 August 2013. https:
//www.python.org/dev/peps/pep-0008/
[33] Django Software Foundation. Coding style. Retrieved 18 June 2015. https://docs.
djangoproject.com/en/1.8/internals/contributing/writing-code/coding-style/
[34] Django Software Foundation. Writing your first Django app, part 1. Database setup.
Retrieved 18 June 2015. https://docs.djangoproject.com/en/1.8/intro/tutorial01/
#database-setup
[35] Massachusetts Institute of Technology. MIT License. Retrieved 21 June 2015. http://
opensource.org/licenses/MIT
[36] Apache Software Foundation. Apache License, Version 2.0. January 2004. http://www.apache.
org/licenses/LICENSE-2.0
1.5
Overview
The remainder of this document consists of three chapters plus a number of appendices. In chapter 2
of this document we give a description of the standards and conventions used in the implementation of
the TravelMatch system. Section 2.1 describes the standards used in constructing the high-level system
design and model. Sections 2.2, 2.3 and 2.4 discuss the standards used in the implementation of the
TravelMatch system on a source code level. Section 2.5 describes the tools used in the development
of the TravelMatch system.
Then, in chapter 3 of this document we give a general description of the various components of the
TravelMatch system. In chapter 4 of this document, we discuss the procedures to build and deploy the
TravelMatch application and back end server. Finally, in the appendices of this document, we provide
the documentation of the source code in the form of source code listings generated from the source
code files.
10
TravelMatch
Detailed Design Document
Chapter 2
Standards and conventions
2.1
Design standards
For the high-level system design, Unified Modeling Language (UML) is used. Specifically, we use UML
for the class diagrams and sequence diagrams. For the Entity-Relation diagram, we define the meaning
of each diagram component as depicted in figure 2.1.
Figure 2.1: Database ER diagram legend
2.2
2.2.1
Documentation standards
General
Every object, class, method and property in the source code must be properly documented inline.
We use ngdoc notation to document the front end code and Doxygen notation for the back end
code. For this document, we use the documentation template in section A.1 for the front end and the
documentation template in section B.1 for the back end.
For every method a contract must be documented which contains at least the following:
ˆ The name of the method.
ˆ A description of the method’s functionality.
ˆ If the method takes parameters, for each parameter the following must be documented:
– The name of the parameter.
11
TravelMatch
Detailed Design Document
– The type of the parameter (e.g. a number, string).
– A description of what the parameter represents.
ˆ If the method returns a value, the following must be documented:
– The return type (e.g. a number, string).
– A description of what the returned value represents.
For every object and class, the following must be documented:
ˆ The name of the object or class.
ˆ A description of the object or class.
For every property, the following must be documented:
ˆ The name of the property.
ˆ A description of the property.
ˆ The type of the property (e.g. a number, string).
2.2.2
AngularJS-specific
For AngularJS code in the front end, additionally the following standards apply:
ˆ For every AngularJS component, it must be documented if the object is a module, controller,
directive or service.
ˆ For every AngularJS directive, an example of the HTML usage must be defined.
ˆ For every AngularJS directive, if it create a new scope, that must be documented.
ˆ For every AngularJS directive, if the directive takes parameters, for each parameter the following
must be documented:
– The name of the parameter.
– The type of the parameter (e.g. a number, string).
– A description of what the parameter represents.
2.3
2.3.1
Naming conventions
Front end
For the front end, the following naming conventions apply.
ˆ File names of AngularJS components must equal the name of that component in lowercase
letters, tokenized by periods.
– For example: HotelService is contained in hotel.service.js.
ˆ With the exception of the app.config module, each file belonging to a certain module must be
contained in a folder with the name of that module, with the app. and any non-alphabetical
characters removed and in lowercase letters.
– For example: app.hotel.overview files are contained in the hoteloverview folder.
ˆ Names of AngularJS modules must begin with app. and can contain only lowercase letters and
periods.
12
TravelMatch
Detailed Design Document
ˆ Names of AngularJS directives follow camelCase practice where the first letter is not capitalized.
ˆ Names of any other AngularJS components follow CamelCase practice where the first letter is
capitalized.
ˆ Names of AngularJS controllers must end with Ctrl.
ˆ Names of AngularJS services must end with Service.
ˆ All names of methods, functions, properties, variables, fields and parameters follow camelCase
practice where the first letter is not capitalized, with the exception of parameters for AngularJS
directives, which must be entirely lowercase.
2.3.2
Back end
For the back end, the following naming conventions apply.
ˆ All models of an application are written in a file named tmodels.py in that application’s subdirectory.
– For example, the models for ai are stored in the ai/models.py.
ˆ All unit tests of an application are written in a file named test.py in that application’s subdirectory.
– For example, the tests for ai are stored in the ai/test.py.
ˆ Administration modules of an application are written in a file named admin.py in that application’s subdirectory.
– For example, the administration modules for ai are stored in the ai/admin.py.
ˆ The interface that examines and validates the input and output of an application is written in a
file named serializer.py in that application’s subdirectory.
ˆ The view controller of an application is written in a file named view.py in that application’s
subdirectory.
ˆ The url routing related codes of an application are written in a file named travelmatch/url.py
in that application’s subdirectory.
ˆ Naming of the classes, functions, methods and variables follows the standard Python naming
conventions.[31]
2.4
Coding standards
Alongside to the above naming standards, the following additional coding standards apply.
2.4.1
Front end
ˆ Use an indenting width of 2 spaces.
ˆ Use spaces, not tabs, for indentation.
ˆ Use the ”One True Brace Style” for indentation.[30]
ˆ DOM manipulation is only allowed in controller and directive methods.
ˆ No HTML may be present in JavaScript source files.
ˆ HTTP requests are only allowed in services.
ˆ Public mutable properties in services are not allowed.
13
TravelMatch
2.4.2
Detailed Design Document
Back end
Following coding standards apply for the back end.
ˆ The standard Python coding standards.[32]
ˆ The standard Django coding standards.[33]
2.5
Software development tools
The following software development tool standards apply.
2.5.1
General
ˆ Git is used for version control.
ˆ GitHub is used for hosting the Git repository.
ˆ LaTeX is used for writing documents.
2.5.2
Front end
ˆ Atom is used for writing code.
ˆ NPM is used for managing development dependencies.
ˆ Bower is used for managing app dependencies.
ˆ Cordova is used to build the app for Android and iOS.
ˆ Ionic is used to test the app on a PC browser.
ˆ gulp is used to automate development tasks.
ˆ ngdoc is used to generate source code documentation.
ˆ pandoc is used to convert ngdoc output to LaTeX.
ˆ karma is used to run JavaScript unit tests.
ˆ Jasmine is used to write JavaScript unit tests.
2.5.3
Back end
ˆ PyCharm is used for writing code in Python.
ˆ WinSCP is used for synchronizing the local directory with the remote sever directory.
ˆ PuTTY is used for SSH commands.
ˆ Doxygen is used to export the Python documentation to Latex.
ˆ Django is used to set up the application and to run Python unit tests.
14
TravelMatch
Detailed Design Document
Chapter 3
Component descriptions
3.1
Front end
ˆ about
The about module consists of the model, view, controller and service for the about screen,
handling and showing everything available in the screen. This module contains a single, simple
controller that shows the iLysian logo and contact information for iLysian.
ˆ details
The details module consists of the model, view, controller and service for the vacation details
screen. This module contains a controller that shows the input fields for the vacation details.
This includes:
– The date of departure;
– The flexibility of the date of departure;
– The date of return;
– The flexibility of the date of return;
– The budget per person;
– A ”surprise me” button for the budget;
– The number of adults;
– The number of children.
– The submission button.
Furthermore, this module contains a service that manages sending and retrieving vacation details
from the back end API.
ˆ front
The front module consists of the model, view, controller and service for the front screen. This
module contains a controller that shows the buttons on the front screen. This includes:
– Continuing without an account (not implemented);
– Connecting with Facebook;
– Logging into a TravelMatch account;
– Registering a TravelMatch account.
ˆ hotelOverview
The hotelOverview module consists of the model, view, controller and service for the hotel
overview and hotel detail screen. This module contains a controller that displays the controls on
the hotel overview screen. This includes:
– Buttons to switch between the first advice and second advice;
– A button to continue the interest analysis;
– Hotel details for every hotel in the advice.
– A booking button for every hotel in the advice.
15
TravelMatch
Detailed Design Document
Furthermore, this module contains a service that manages sending and retrieving recommendations from the back end API.
ˆ registration
The registration module consists of the model, view, controller and service for the registration
of users. This module contains a controller that shows the input fields of the registration screen.
This includes:
– The e-mail field;
– The password field;
– The repeat password field;
– The submission button;
– The connect with Facebook button.
Furthermore, this module contains a service that manages registering in the back end API.
ˆ main
The main module consists of the authentication service, HTTP interceptor and the constant
values. This module contains a service that manages the user’s session. Furthermore, it contains
a service that intercepts all HTTP requests. Any strings in query parameters are encoded to
prevent data loss. Also, generic HTTP errors are caught and resolved before they reach the
caller. Finally, this module contains a number of global constants for the app.
ˆ language
The language module consists of the language files for each language one. This module contains
a language file for Dutch and English language.
ˆ login
The login module consists of the model, view, controller and service of the login screen for all
authentication providers. This module contains a controller that shows the input fields of the
login screen. This includes:
– The e-mail field;
– The password field;
– The submission button;
– The connect with Facebook button.
Furthermore, this module contains a service that manages logging in in the back end API.
Additionally, this module contains the directive for the Facebook button, which displays a connect
with Facebook button and manages Facebook authentication in the external API.
ˆ navigation
The navigation module consists of the models, views and controller of the header, sidebar and
tabs of the login and registration screen. This module contains a main controller which contains
common functionality that is used in all other controllers of this module. Furthermore, it contains
several directives:
– A directive for the header that displays the state name, back button and menu button;
– A directive for the sidebar menu that displays buttons for every state in the sidebar menu;
– A directive for the menu button in the header;
– A directive for tabs in the login and registration screens, that allow the user to switch
between the two.
16
TravelMatch
Detailed Design Document
ˆ swipe
The swipe module consists of the models, views, controller and service of the interest analysis
named after the associated swiping of images. This module contains a photo directive which
displays the photos being shown in the interest analysis, as well as the like/dislike buttons and
progress bar. Furthermore, it contains a service that manages retrieving images and sending
(dis)likes to the back end API. The photo directive is governed by a controller which obtains
images from the service and routes them into the photo directive.
ˆ user
The user module consists of the model, view, controller and service of the user detail screen.
This module contains a controller that displays the input fields of the user profile. This includes:
– The name of the user;
– The gender of the user;
– The birth date of the user;
– The submission button.
Furthermore, this module contains a service that manages retrieving and storing user info in the
back end API.
3.2
Back end
ˆ Affiliate
The Affiliate component pulls data from an affiliate feed and translates it into the TravelMatch
data model. It contains functionality to add, modify and remove feeds and parsers for the feeds.
ˆ AI
The AI component contains the the implementation of the decision making algorithms in TravelMatch. The AI component can calculate which images should be presented next in interest
analysis, and give a holiday recommendation based on Travel DNA.
ˆ Authentication token verification
The Authentication token verification component provides functionality to verify the authenticity
of JSON Web Tokens.
ˆ CMS
The CMS component contains the hooks of the Content Management System, so that it can
trigger the affiliate parser, and allow administrators to change data via a user interface.
ˆ Database
The Database component contains the TravelMatch data model, and stores all data according
to it.
ˆ Facebook authentication
The Facebook authentication component checks with the Facebook servers whether the Facebook
token provided by the client is valid.
ˆ Interest analysis API
The Interest analysis API component holds the API functions for the interest analysis swiping.
It allows functionality to start, query and update vacations, get new images for interest analysis
and record likes and dislikes.
ˆ Recommendation API
The Recommendation API component holds the API functions for the holiday recommendations:
getting a recommendation, getting a location’s trips, and saving, loading and deleting a location
overview.
17
TravelMatch
Detailed Design Document
ˆ Registration / login API
The Registration / login API component holds the API functions for user registration and login.
This includes registering and logging in via e-mail or Facebook, activating an e-mail account,
delete accounts, querying and updating user details and creating and deleting guest accounts.
18
TravelMatch
Detailed Design Document
Chapter 4
Build procedure
4.1
Front end
The TravelMatch app can be built and deployed by following the below procedure.
4.1.1
Prerequisites
1. The build PC is prepared for building on Android or iOS.
2. NPM is installed.
3. Git is installed.
4.1.2
Build process
1. Clone the TravelMatch Git repository.
2. Open a console window with admin/superuser privileges and go to the src folder:
ˆ cd src
3. Create the output directory:
ˆ mkdir www
4. Use NPM to install gulp, Bower, Cordova and Ionic:
ˆ npm install gulp bower cordova ionic
5. Install karma-cli globally.
ˆ npm install karma-cli -g
6. Install all development dependencies:
ˆ npm install
7. Add Android and/or iOS as Cordova platforms. Note that adding iOS is only possible on PC
running OS X.
ˆ cordova platform add android
ˆ cordova platform add ios
8. Install all app dependencies:
ˆ gulp cook
9. Building the app for either Android or iOS:
ˆ gulp android
ˆ gulp ios
19
TravelMatch
4.2
Detailed Design Document
Back end
The TravelMatch server can be built and deployed by following the below procedure.
4.2.1
Prerequisites
1. Ubuntu 14.04 LTS or a compatible version is running on the server.
2. Python 2.7.6 or a compatible version is installed on the server.
4.2.2
Building server
1. Install Django via pip with following command:
ˆ sudo python get-pip.py
ˆ git clone git://github.com/django/django.git django-trunk
ˆ sudo pip install -e django-trunk/
ˆ sudo pip install djangorestframework
2. Install Mailgun.
ˆ sudo pip install -e git://github.com/mailgun/mailgun.py.git#egg=pymailgun
3. Install related Django packages.
ˆ sudo pip install django facebook
4. Make migrations for the database in the ∼/TravelMatch/server/travelmatch folder.
ˆ python manage.py make migrations
5. Set up the database. The database has the SQLite engine as its default configuration. This
configuration can be changed in the settings.py file. The DATABASES variable must be set
according to the Django tutorial.[34] An example of a MySQL configuration may be found below.
DATABASES = {
’ default ’ : {
’ ENGINE ’ : ’ d j a n g o . db . b a c k e n d s . mysql ’ ,
’NAME’ : ’DB NAME’ ,
’USER ’ : ’ DB USER ’ ,
’PASSWORD’ : ’DB PASSWORD’ ,
’HOST ’ : ’ l o c a l h o s t ’ ,
’PORT ’ : ’ 3 3 0 6 ’ ,
}
}
6. Initialize the database.
ˆ python manage.py migrate
7. Start the server.
ˆ python manage.py runserver 0.0.0.0:80
20
TravelMatch
Detailed Design Document
Appendix A
Front end documentation
A.1
Documentation template
Each object in the front end documentation is documented with the following template:
Name of object
Description of the object.
Methods (if applicable)
ˆ nameOfMethod(parameterName)
This method is private. (if applicable)
Description of the method.
Parameters
Param
Type
Details
parameterName
Type of the parameter
Description of the parameter
Returns (if applicable)
return type
Description of the return value
Properties (if applicable)
ˆ nameOfProperty
This property is private. (if applicable)
Description of the property.
Type: type of the property
A.2
app.about
The app.about module contains all templates and controllers that pertain to the about screen of the
app.
A.2.1
AboutCtrl
The AngularJS controller for the about screen.
A.2.2
AnalyticsService
Provides methods for recording events for analytics purposes.
21
TravelMatch
Detailed Design Document
Methods
ˆ getDevice()
Gets all device information available
Returns
Object
device device information
ˆ sendEvent(eventName, category, data)
Sends the specified event with the specified category to the analytics, with the specified data. If
the user is authenticated, the user info is also sent.
Parameters
Param
Type
Details
eventName
category
string
string
data
string
The name of the event.
The name of the category of
the event.
The data to send.
A.3
app.config
The app.config module is a special module that contains global settings and configurations for the
entire app. This module exposes a number of constants as well as special services.
A.3.1
HttpInterceptor
A factory that acts as an interceptor for the AngularJS $http service. It extends the $http service with
the following features:
ˆ A Content-Type: application/json HTTP header is automatically added to all HTTP requests.
ˆ If a user is authenticated, their authentication token is automatically added to the Authorization
HTTP header.
ˆ All string parameters for HTTP GET requests are automatically encoded to URL-safe Base64
encoding as per RFC 4648. This is a regular Base64 encoding with the following differences:
– - is used in place of +
– ‘ ’ is used in place of /
– All trailing = are trimmed.
Methods
ˆ encode(s)
This method is private.
Encodes the given string with URL-safe Base64 encoding as per RFC 4648.
Parameters
Param
Type
Details
s
string
The string to encode.
22
TravelMatch
Detailed Design Document
Returns
string
The string encoded with URL-safe Base64
encoding as per RFC 4648.
ˆ encodeAll(obj)
This method is private.
Encodes all properties with type string in the provided object with URL-safe Base64 encoding
as per RFC 4648. Properties that do not have the type string are ignored. Furthermore, this
method does not support recursion; a string in an Object in the provided Object, for instance,
will not be encoded.
This method does not return anything; rather, the provided object is modified in place.
Parameters
Param
Type
Details
obj
Object
The object to encode all
strings in.
ˆ request(config)
Modifies the provided HTTP configuration object, applying the features as listed above. This
HTTP configuration object follows the same format as the config parameter in the $http
AngularJS service.
Parameters
Param
Type
Details
config
Object
The HTTP configuration
object to modify.
Returns
Object
A.3.2
The modified HTTP configuration object.
BACK BUTTON
Defines the behavior of the back button for each routing state. Each property in the object has the
following format:
ˆ key - The internal routing name for the current state.
ˆ value - The internal routing name for the state to transition to when the back button is pressed.
Type: Object
A.3.3
BASE URL
Defines the base URL of the back end REST API. Changes to this constant affect all TravelMatch
back end API calls throughout the entire app. API calls to third party APIs, such as Facebook, are
not affected.
Type: string
23
TravelMatch
A.3.4
Detailed Design Document
DEBUG URL
Defines the URL of the debugging server to use. Changes to this constant affect all DebugService
calls.
Type: string
A.3.5
SHOW SWIPE DEBUG
Whether or not to show swipe debug overlay.
Type: boolean
A.3.6
STATE NAMES
Defines the names of each routing state, to be shown in the header and menu. Each property in the
object has the following format:
ˆ key - The internal routing name for the state.
ˆ value - A $translate ID for the name of the state.
Type: Object
A.3.7
USE DEBUG
Whether or not to enable debugging functionality.
Type: boolean
A.3.8
USE FRONT
Whether or not to include the front screen.
Type: boolean
A.3.9
AuthService
Manages user authentication data, including the storage and retrieval of tokens. User info is stored in
local storage as an object with the following properties:
ˆ Identity - The string that represents the user’s identity.
ˆ Token - The authentication token of the user.
Methods
ˆ existsUserInfo()
Checks if user info exists for one or more users.
Returns
boolean
true if user info exists and is not null;
otherwise, false.
ˆ getUserInfo()
Retrieves all stored user info.
Returns
Object
The user info stored in local storage, or null if
no user info was found.
24
TravelMatch
Detailed Design Document
ˆ isAuthenticated(id)
Checks whether a particular user is authenticated.
Parameters
Param
Type
Details
id
string
The identity of the user to
compare against.
Returns
boolean
true if the given user is authenticated;
otherwise, false.
ˆ logout()
Logs the user out and removes all user info. Internally, this is simply an alias for removeUserInfo().
ˆ removeUserInfo()
Removes all user info.
ˆ setUserInfo(user, token)
Stores the given user info.
Parameters
Param
Type
Details
user
string
token
string
The string that represents the
identity of the user.
The authentication token of
the user.
A.4
app.debug
The app.debug module contains all services that pertain to debugging of the app.
A.4.1
DebugService
Provides methods for remote debugging.
Methods
ˆ debug(log)
Posts the specified object to the debug server, if and only if USE DEBUG is set to true.
Parameters
Param
Type
Details
log
Object
The object to log.
Returns
25
TravelMatch
Detailed Design Document
HttpPromise
A.5
A promise of the post. If USE DEBUG is set to
false, this method instead returns a promise
that resolves immediately.
app.details
The app.details module contains all templates and controllers that pertain to the vacation details
screen of the app.
A.5.1
DetailCtrl
The AngularJS controller for the vacation details screen.
Methods
ˆ checkForm()
This method is private.
Validates the vacation details form to check if all fields are filled in correctly. If this is not the
case, an error pop-up is shown.
Returns
boolean
true if all fields are valid; otherwise, false.
ˆ init()
This method is private.
Initializes this controller. Functionality of this method includes:
–
–
–
–
–
Displaying a pop-up with instructions on the first time ever opening this screen.
Retrieving the vacation details from the back end server.
Entering the vacation details of the last vacation into the model.
Checking the “Surprise me!” checkbox if the budget equals 0.
Showing an error pop-up if retrieval of the vacation details failed.
ˆ showInfo()
Shows a popup with instructions for the user.
ˆ submit()
This method is private.
Validates and posts the vacation details to the back end API. If this is successful, the user is
transferred to the interest analysis screen; otherwise, an error pop-up is shown.
Properties
ˆ vacation
Represents the model of the vacation details input fields.
Object properties:
– start date - The Date of departure for the vacation.
– end date - The Date of return for the vacation.
26
TravelMatch
–
–
–
–
–
–
–
Detailed Design Document
start date extend - The amount of days that the start date may be off.
end date extend - The amount of days that the end date may be off.
persons adults - The number of adults.
persons children - The number of children.
vac id - The vacation details ID for the current vacation details.
noBudget - Whether the user has checked Surprise me!
budget - The maximum budget of the user. If set to 0, the budget is not be taken into
account.
Type: Object
A.5.2
VacationDetailsService
Provides methods for getting and setting the vacation details from the back end. The last vacation
details received from the back end server are cached until new vacation details are obtained.
Methods
ˆ apiToVac()
This method is private.
Converts an object received from the back end server API to a vacation details object.
ˆ clear()
Clears the cached set of vacation details.
ˆ createVacation(vac)
Creates new vacation details in the back end server with the specified parameters. The promise
returned by this method is resolved if the vacation details were successfully created; otherwise,
it is rejected with the translation ID of the error that occurred.
If the vacation details were created successfully, they are added to the cached set of vacation
details.
Parameters
27
TravelMatch
Detailed Design Document
Param
Type
Details
vac
Object
The vacation details. This
object has the following
properties:
– name - The name of the
vacation details.
– startDate - The Date
of departure.
– startRange - The
number of days that the
startDate may be off.
– endDate - The Date of
return.
– endRange - The
number of days that the
endDate may be off.
– adults - The number
of adults.
– children - The
number of children.
– budget - The budget
for the vacation. If set
to 0, the budget is not
taken into account.
Returns
Promise
A promise of the vacation details creation.
ˆ currentVacations()
Gets the last set of vacation details that were retrieved or sent to the back end server.
Returns
28
TravelMatch
Detailed Design Document
Array.<Object>
The set of vacation details, or an empty array if
no vacation details are available. Each object
has the following properties:
– id - The ID of the vacation details.
– name - The name of the vacation details.
– swipes - The number of swipes left
before a new recommendation can be
obtained.
– startDate - The Date of departure.
– startRange - The number of days that
the startDate may be off.
– endDate - The Date of return.
– endRange - The number of days that the
endDate may be off.
– adults - The number of adults.
– children - The number of children.
– budget - The budget for the vacation. If
set to 0, the budget is not taken into
account.
ˆ deleteVacation(id)
Deletes the vacation details with the specified ID in the back end server. The promise returned by
this method is resolved if the vacation details were deleted successfully; otherwise, it is rejected
with the translation ID of the error that occurred.
If the vacation details with the specified ID exist in the set of cached vacation details, then they
are deleted from the set.
Parameters
Param
Type
Details
id
number
The ID of the vacation details
to delete.
Returns
Promise
A promise of the vacation details deletion.
ˆ findVacation(id)
This method is private.
Finds the index of the vacation details with the specified ID in the cached set of vacation details.
Parameters
Param
Type
Details
id
number
The ID of the vacation details
to find.
29
TravelMatch
Detailed Design Document
Returns
number
The index of the vacation details in the cached
set of vacation details, or -1 if the vacation
details were not found.
ˆ getLatestVacation()
Retrieves the ID of the last saved vacation details from the back end server. The promise returned
by this method is resolved if the ID of the last saved vacation details were retrieved successfully;
otherwise, it is rejected with the translation ID of the error that occurred.
Returns
Promise
A promise of the last saved vacation details
retrieval.
ˆ getVacations()
Retrieves the set of vacation details of the current user from the back end server. Additionally,
this method also retrieves the latest vacation details that were saved. The promise returned by
this method is resolved if both retrievals succeeded; otherwise, it is rejected with the translation
ID of the error that occurred.
Returns
Promise
A promise of the vacation details retrieval.
ˆ latestVacation()
Returns the vacation details that were last saved, or null if the last saved vacation details have
not been retrieved from the back end server yet.
Returns
Object
The last saved vacation, with the following
properties, or null:
ˆ setVacations(vacs)
This method is private.
Sets the cached set of vacation details to the specified set of vacation details.
Parameters
Param
Type
Details
vacs
Array.<Object>
The set of vacation details.
ˆ updateVacation(id, vac)
Updates the vacation details with the specified ID in the back end server with the specified parameters. The promise returned by this method is resolved if the vacation details were successfully
updated; otherwise, it is rejected with the translation ID of the error that occurred.
If the vacation details with the specified ID exist in the set of cached vacation details, then they
are updated in the set.
30
TravelMatch
Detailed Design Document
Parameters
Param
Type
Details
id
number
vac
Object
The ID of the vacation details
to update.
The vacation details. This
object has the following
properties:
– name (optional) - The
name of the vacation
details.
– startDate (optional) The Date of departure.
– startRange (optional)
- The number of days
that the startDate
may be off.
– endDate (optional) The Date of return.
– endRange (optional) The number of days
that the endDate may
be off.
– adults (optional) - The
number of adults.
– children (optional) The number of children.
– budget (optional) - The
budget for the vacation.
If set to 0, the budget is
not taken into account.
Returns
Promise
A promise of the vacation details update.
ˆ vacToApi()
This method is private.
Converts the specified vacation details to the object format requested by the back end server
API.
Properties
ˆ latestVacationId
This property is private. Use latestVacation().vac id.
The ID of the last vacation details that were saved that was last retrieved from the back end
server, or null if the last vacation details were never retrieved.
Type: number
31
TravelMatch
Detailed Design Document
ˆ vacations
This property is private. Use currentVacations().
The last set of vacation details retrieved from the back end server.
Type: Array.<Object>
A.6
app.front
The app.front module contains all templates and controllers that pertain to the front screen.
A.6.1
FrontCtrl
The AngularJS controller for the front screen.
Methods
ˆ checkUser()
Checks if user is already logged in, and if so, forwards the user to the vacation details screen.
This method is called upon initialization of the controller.
ˆ continueWithoutAccount()
Sends the device ID to the back end server to continue as guest. If the device ID is undefined,
or guest account authentication failed, an error pop-up is shown. Otherwise, the user obtains a
guest account and is forwarded to the vacation details screen.
ˆ fbLogin()
Performs a Facebook login.
A.7
app.hotel.overview
The app.hotel.overview module contains all templates and controllers that pertain to the hotel
overview screen.
A.7.1
HotelOverviewCtrl
The AngularJS controller for the hotel overview screen.
Methods
ˆ furtherAnalysis()
Redirects the user to the interest analysis screen.
ˆ init()
Initializes this controller. Functionality of this method includes:
– Entering the last retrieved recommendations into the model.
– Retrieving a set of recommendations if no cached recommendations are currently available.
– Showing an error pop-up if retrieval of recommendations failed.
ˆ openInBrowser(link)
Opens the specified link in the device’s standard external browser.
Parameters
32
TravelMatch
Detailed Design Document
Param
Type
Details
link
string
The link to open.
ˆ showAdvice(index)
Displays the recommendation at the specified index in the model. If this is the first time that
the recommendation is opened, the event is also recorded in the analytics.
Parameters
Param
Type
Details
index
number
The index of the
recommendation.
ˆ showDescription(event)
Expands the description of the clicked trip offer, and closes any other open descriptions.
Parameters
Param
Type
Details
event
Event
The $event object received
from ngClick.
Properties
ˆ recommendations
The model for the trip offers shown in the hotel overview screen. Each object in the array has
the following properties:
– location - The location of the recommendation, with the following properties:
* city name - The name of the city.
* region name - The name of the region.
* country name - The name of the country.
– offers - The trip offers associated with the recommendation, with the following properties:
*
*
*
*
*
*
*
*
*
*
*
offer id - The ID of the trip offer.
name - The name of the trip offer.
description - The description of the trip offer.
price - The price of the trip offer, in euro cents.
link - The affiliate link to book the trip offer.
image - The URL for an image of the trip offer.
hotel stars - The Hotelstars rating for the trip offer.
min people - The minimum number of people for the trip offer.
dept date - The departure date for the trip offer.
duration days - The duration, in days, for the trip offer.
user rating - The user rating for the trip offer.
Type: Array.<Object>
ˆ selected
The index of the currently selected recommendation in the recommendations property.
Type: number
33
TravelMatch
A.7.2
Detailed Design Document
HotelService
Provides methods for getting and setting the hotel recommendations and hotel info from the back end.
The last recommendations received from the back end server are cached until new recommendations
are obtained.
Methods
ˆ deleteRecommendation(recId)
Deletes the cached recommendation at the specified index in the back end server. The promise
returned by this method is resolved if the deletion was successful; otherwise, it is rejected with
the translation ID of the error that occurred.
Note: If the deletion is successful, the recommendation is also deleted from the cached recommendations. This causes the index of all recommendations that follow it to be updated!
Parameters
Param
Type
Details
recId
number
The index of the
recommendation to delete.
Returns
Promise
A promise of the recommendation deletion.
ˆ getNewRecommendations(vacId, n)
Gets new recommendations from the back end server and caches them in the hotel service.
The promise returned by this method is resolved if the hotel recommendations were successfully
retrieved; otherwise, it is rejected with the translation ID of the error if the retrieval failed.
Parameters
Param
Type
Details
vacId
number
n
number
The ID of the vacation details
to take into account.
The number of
recommendations to retrieve.
Returns
Promise
A promise of the recommendations retrieval.
ˆ lastRecommendations()
Gets the last recommendations that were retrieved from the back end server.
Returns
Array.<Object>
The recommendations.
ˆ loadRecommendation(locId, renew)
34
TravelMatch
Detailed Design Document
Loads a recommendation for the specified location from the back end server. An optional parameter renew indicates whether the trip offers should be renewered, or the previous trip offers
should be returned. The promise returned by this object is resolved if the retrieval was successful;
otherwise, it is rejected with the translation ID of the error that occurred.
Parameters
Param
Type
Details
locId
number
renew
boolean
The ID of the location to get
new trip offers for.
Whether to renew the trip
offers.
(default: false)
Returns
Promise
A promise of the trip offers retrieval.
ˆ recommendationCount()
Gets the number of recommendations currently cached in the HotelService.
Returns
number
The number of recommendations.
ˆ saveRecommendation(recId)
Saves the cached recommendation at the specified index in the back end server. The promise
returned by this object is resolved if the storage was successful; otherwise, it is rejected with the
translation ID of the error that occurred.
Parameters
Param
Type
Details
recId
number
The index of the
recommendation to save.
Returns
Promise
A promise of the recommendation storage.
ˆ setRecommendations(recs)
This method is private.
Sets the cached recommendations to the specified recommendations and returns a boolean that
indicates whether the storage succeeded or failed.
Parameters
Param
Type
Details
recs
Array.<Object>
The recommendations.
35
TravelMatch
Detailed Design Document
Returns
boolean
true if the storage succeeded; otherwise,
false.
ˆ validateOffers(offers)
This method is private.
Validates the specified trip offers, checking if the trip offers match the specification.
Parameters
Param
Type
Details
offers
Array.<Object>
The array of offers.
Returns
boolean
true if the offers are valid; otherwise, false.
ˆ validateRecommendations(recs, expectedCount)
This method is private.
Validates the specified recommendations, checking if the recommendations match the specification.
Parameters
Param
Type
Details
recs
Array.<Object>
expectedCount
number
The array of
recommendations.
The minimum number of
recommendations expected.
(default: 0)
Returns
boolean
true if the recommendations are valid;
otherwise, false.
Properties
ˆ recommendations
This property is private. Use lastRecommendations().
An array of the last recommendations retrieved from the back end server. Each object has the
following properties:
– location - The location of the recommendation, with the following properties:
* city name - The name of the city.
* region name - The name of the region.
* country name - The name of the country.
36
TravelMatch
Detailed Design Document
– offers - The trip offers associated with the recommendation, with the following properties:
*
*
*
*
*
*
*
*
*
*
*
offer id - The ID of the trip offer.
name - The name of the trip offer.
description - The description of the trip offer.
price - The price of the trip offer, in euro cents.
link - The affiliate link to book the trip offer.
image - The URL for an image of the trip offer.
hotel stars - The Hotelstars rating for the trip offer.
min people - The minimum number of people for the trip offer.
dept date - The departure date for the trip offer.
duration days - The duration, in days, for the trip offer.
user rating - The user rating for the trip offer.
Type: Array.<Object>
A.8
app.login
The app.login module contains all templates, controllers and services that pertain to the login screen
of the app.
A.8.1
LoginCtrl
The AngularJS controller for the login screen. The login screen currently supports logging in with
e-mail address and password, or by connecting with Facebook.
Methods
ˆ fbLogin()
Performs a Facebook login.
ˆ init()
This method is private.
Initializes this controller. Functionality of this method includes:
– Setting the value of the e-mail field to the last e-mail address used for successful registration.
ˆ login()
Performs a login with the current values of the e-mail address and password input fields. If the
login fails, an error pop-up is shown; otherwise, a success pop-up is shown and afterwards the
user is transferred to the vacation details screen. This method also clears the password input
field.
Properties
ˆ data
Represents the model of the credentials input fields.
Object properties:
– username - The value of the e-mail address input field.
– password - The value of the password input field.
Type: Object
37
TravelMatch
A.8.2
Detailed Design Document
facebookButton
A Facebook login button that can be used to authenticate TravelMatch with Facebook. If clicked, the
user is asked to authorize the TravelMatch app and an account is made in the back end server. After
this, the user is logged in.
Usage
as attribute
<ANY facebook-button>
...
</ANY>
Directive info
ˆ This directive creates new scope.
Methods
ˆ login()
Performs a login via Facebook. If the Facebook SDK has not been loaded, then an error pop-up
is shown instead.
The login function is called in the Facebook SDK, which opens Facebook in a new window. Here,
the user is asked to log in to Facebook if not already logged in, and then is asked to authorize
the TravelMatch app to use their account.
Successful Facebook authorization is followed by an API call to the back end server to create a
new user in the database with the Facebook ID obtained from the Facebook API, and/or obtain
the existing TravelMatch authentication token for that user.
If both Facebook authorization and TravelMatch registration/login are successful, a success popup is shown and afterwards the user is transferred to the vacation details screen. If either failed,
an error pop-up is shown.
This method requests the following Facebook permissions:
– public profile - Included by default in any Facebook app authorization request. Needed
to obtain the app-specific Facebook ID as well as the Facebook authentication token, which
is verified in the back end to confirm the authorization.
Returns
Promise
A.8.3
A promise of the Facebook login.
LoginService
Provides methods for logging in to TravelMatch accounts in the back end.
Methods
ˆ loginUser(id, token, use)
Performs a login action in the back end API using the specified authentication provider, with the
specified identity string and token.
Facebook Login with this method is only availabld if the Facebook ID and token are
known beforehand.
38
TravelMatch
Detailed Design Document
Parameters
Param
Type
Details
id
string
token
string
use
string
The string that represents the
identity of the user, i.e. the
user’s e-mail address or
Facebook app-specific ID.
A token that provides
authentication of the user, i.e.
the user’s password or
Facebook authentication
token.
The authentication provider
to use. This parameter can
have the following values:
– email - Use a
combination of e-mail
address and password to
log in.
– facebook - Use a
combination of
Facebook app-specific
ID and authentication
token to log in. This
value is deprecated.
Returns
Promise
A.9
A promise of the user login action that is
resolved if the login was successful or rejected
with the translation ID of the error if the login
failed.
app.module
The app.module module contains all templates and controllers that pertain to the vacation details
screen of the app.
A.10
app.navigation
The app.navigation module contains all templates and directives that pertain to the header bar,
menu sidebar and navigation of the app.
A.10.1
MainCtrl
The AngularJS controller for the persistent elements of the app, which includes the header bar and
menu sidebar. This controller adds functions to the scope that allow any element that inherits from it
to open or close the menu sidebar at will.
39
TravelMatch
Detailed Design Document
Methods
ˆ goBack()
Sends the user back to the state taken from BACK BUTTON. If the current state has no back
button state, then the user will be sent to the previous state.
ˆ hideMenu()
Hides the menu sidebar, if it is currently open.
ˆ isMenuOpen()
Checks whether the menu sidebar is currently open or closed.
Returns
boolean
true if the menu sidebar is currently open;
false if the menu sidebar is currently closed.
ˆ showMenu()
Shows the menu sidebar, if it is currently closed.
ˆ toggleMenu()
Toggles the display of the menu sidebar: the menu sidebar is opened if it is currently closed, or
closed if it is currently open.
A.10.2
tmHeader
A persistent header bar that is shown at the top of every screen in the app. This header shows the
title of the current state of the app, the menu button, and a back button if the current state supports
it. The header bar is hidden upon a transition to a full screen state, and adds a toggle button to open
or close it in such a state.
Usage
as element:
<tm-header>
</tm-header>
Methods
ˆ addStateListeners()
This method is private.
Adds a listener to the $stateChangeStart event in the $rootScope that is fired upon starting
a transition to a different state. This listener prepares the header for the transition to that state.
ˆ getTitle()
Gets the title of the current state. This title is taken from STATE NAMES.
Returns
string
The title of the current state.
ˆ init()
40
TravelMatch
Detailed Design Document
This method is private.
Initializes this directive. Functionality of this method includes:
– Registering the native back button.
– Adding state listeners.
– Preparing for the current state.
ˆ isFullScreenState()
Checks whether the current state is a full screen state. Only the tm.main.swipe state is a full
screen state, so this method simply compares the name of the current state to that.
Returns
boolean
true if the current state is a full screen state;
otherwise, false.
ˆ isHeaderlessState()
Checks whether the current state is a headerless state. Only the tm.front state is a full screen
state, so this method simply compares the name of the current state to that.
Returns
boolean
true if the current state is a headerless state;
otherwise, false.
ˆ prepareState(toState)
This method is private.
Prepares the header for a transition to the specified state. If the state is a full screen state, then
the header is hidden and the toggle button displayed. Also, the back button is displayed if the
state has a back button state defined.
Parameters
Param
Type
Details
toState
string
The state that the app is
about to transition to.
ˆ registerBackButton()
This method is private.
This method registers the function of the native back button on devices that support it, such
as Android-based devices. If the native back button is pressed, the app transitions to the back
button state as defined in BACK BUTTON. If no back button state has been defined for the
current state, then the back button exits the app.
ˆ toggleHeader()
Toggles the display of the header: hiding it if the header is visible, or showing it if the header is
not visible. Additionally, if the menu sidebar is open, this method also closes it.
A.10.3
tmLoginTabs
The tabs shown at the top of the login and registration screens, that allow the user to switch between
the two screens. This directive provides no further content.
41
TravelMatch
Detailed Design Document
Usage
as element:
<tm-login-tabs>
</tm-login-tabs>
A.10.4
tmMenu
A persistent menu sidebar that slides in from the right, with a set of options that can change depending
on whether the user is authenticated or not.
Usage
as element:
<tm-menu>
</tm-menu>
Methods
ˆ isLoggedIn()
Checks whether the user is currently authenticated or not.
Returns
boolean
true if the user is authenticated; otherwise,
false.
ˆ logout()
Hides the menu sidebar, removes all authentication data of the current user and shows a pop-up
message notifying the user that they have been logged out. Afterwards, the user is transferred
to the front screen, or to the login screen if USE FRONT is false.
Properties
ˆ states
An array of menu option objects that can be shown in the menu sidebar. The menu options are
shown in the same order that they are defined in this array. Each menu option object has the
following properties:
– state - The state to transition to when this menu option is pressed.
– name - The translation ID for the name to show on the menu option. If this name is
undefined, then the translation ID is taken from STATE NAMES instead.
– needAuth - Controls when the menu option is displayed based on whether the user is
authenticated or not. This property can take one of the following values:
* true - The menu option is only displayed when the user is authenticated.
* false - The menu option is only displayed when the user is not authenticated.
* undefined - The menu option is always displayed, regardless of whether the user is
authenticated or not.
– click - The name of the function to call when the menu option is selected. This function
must be defined in the scope of this directive. If this property is undefined, then the menu
sidebar is hidden when the menu option is selected.
Type: Array.<Object>
42
TravelMatch
A.10.5
Detailed Design Document
tmMenuButton
The menu button used in the header bar. This directive provides no further content.
Usage
as element:
<tm-menu-button>
</tm-menu-button>
A.11
app.registration
The app.registration module contains all templates, controllers and services that pertain to the
registration screen of the app.
A.11.1
RegistrationCtrl
The AngularJS controller for the registration screen. The registration screen currently supports registering with an e-mail address and password.
Methods
ˆ register()
Performs an account registration with the current values of the e-mail address and both password
input fields. If the registration fails, an error pop-up is shown. Otherwise, a success pop-up is
shown telling the user to check their e-mail for the activation link, and afterwards the user is
transferred to the login screen. This method also clears the password input fields.
Properties
ˆ data
Represents the model of the credentials input fields.
Object properties:
– username - The value of the e-mail address input field.
– password - The value of the first password input field.
– password2 - The value of the second password input field.
Type: Object
A.11.2
RegistrationService
Provides methods for registering TravelMatch accounts in the back end.
Methods
ˆ FBRegister(fbuser, fbtoken)
Registers a new user in the back end server with the specified Facebook app-specific ID and Facebook authentication token. The promise returned by this method is resolved if the registration
was successful, or rejected with the translation ID of the error that occurred if the registration
failed.
Parameters
43
TravelMatch
Detailed Design Document
Param
Type
Details
fbuser
string
fbtoken
string
The Facebook app-specific ID
of the user.
The Facebook authentication
token of the user.
Returns
Promise
A promise of the registration.
ˆ lastEmail()
Returns the last e-mail address used for successful registration in this app session.
Returns
string
The e-mail address, or null if no e-mail
registration succeeded in this session.
ˆ registerUser(email, pw, pw2)
Registers a new user in the back end server with the specified e-mail address and password. The
promise returned by this method is resolved if the registration was successful, or rejected with
the translation ID of the error that occurred if the registration failed. After registration, the user
must click an activation link in their e-mail before they may login.
Parameters
Param
Type
Details
email
string
pw
string
pw2
string
The e-mail address of the
user.
The desired password of the
user.
A repeat of the desired
password, for validation
purposes.
Returns
Promise
A promise of the registration.
Properties
ˆ email
This property is private. Use email().
The last e-mail address used for successful registration in this session.
Type: string
44
TravelMatch
A.12
Detailed Design Document
app.swipe
The app.swipe module contains all templates, controllers, services and directives that pertain to the
interest analysis screen of the app.
A.12.1
SwipeCtrl
The AngularJS controller for the interest analysis screen.
Methods
ˆ checkNeedsMore()
This method is private.
Checks whether the image buffer contains enough images to finish the current interest analysis
without having to retrieve additional images. Additionally, this method updates $scope.needsMore.
Returns
boolean
true if more images are needed; otherwise,
false.
ˆ imageError(data)
This method is private.
Displays the specified error message in a pop-up, then transfers the user to the vacation details
screen.
Parameters
Param
Type
Details
data
string
The translation ID of the error
message.
ˆ imageSuccess(images)
This method is private.
Receives images from the ImageService and stores them in the image buffer in the model. If no
images are supplied, an error pop-up is shown instead.
Parameters
45
TravelMatch
Detailed Design Document
Param
Type
Details
images
Array.<Object>
An array of image objects,
with the following properties:
– id - The ID of the
image.
– url - The URL of the
image.
– width - The width of
the image, in pixels.
– height - The height of
the image, in pixels.
ˆ init()
Initializes this controller. Functionality of this method includes:
– Redirecting the user to the vacation details screen if the vacation details are unavailable.
– Retrieving the initial set of images.
– Setting the limit of the current interest analysis.
ˆ onSwipe(imageId, choice)
Posts a (dis)like for the specified image to the back end and retrieves the next image.
Parameters
Param
Type
Details
imageId
number
choice
boolean
The image ID of the image
that was (dis)liked.
true to post a like; false to
post a dislike.
Properties
ˆ currentProgress
The current progress of the interest analysis.
Type: number
ˆ images
An array of image objects to use as the model for the swipeable images, with the following
properties:
–
–
–
–
id - The ID of the image.
url - The URL of the image.
width - The width of the image, in pixels.
height - The height of the image, in pixels.
Type: Array.<Object>
ˆ isDone
46
TravelMatch
Detailed Design Document
Whether the current interest analysis is done. This property is updated whenever checkNeedsMore
is called.
Type: boolean
ˆ limit
The amount of images shown per interest analysis.
Type: number
ˆ needsMore
Whether the current interest analysis requires more images to be loaded from the server in order
to finish. This property is updated whenever checkNeedsMore is called.
Type: boolean
A.12.2
tmPhoto
A container for the swiping interface in the interest analysis screen. This directive is powered by an
image buffer from which the images to swipe are drawn. The top image in the buffer can be dragged
to the left or right to indicate a dislike or like respectively. This directive also generates buttons on the
bottom that can be used to (dis)like an image. Upon (dis)liking an image, a callback function can be
called.
Usage
as element:
<tm-photo
images="{Array.<Object>}"
onchoice="{expression}"
needsmore="{boolean}"
isdone="{boolean}">
</tm-photo>
Directive info
ˆ This directive creates new scope.
Param
Type
Details
images
Array.<Object>
An array of image objects to
use as the model for the
swipeable images, with the
following properties:
ˆ id - The ID of the
image.
ˆ url - The URL of the
image.
ˆ width - The width of
the image, in pixels.
ˆ height - The height of
the image, in pixels.
47
TravelMatch
Detailed Design Document
Param
Type
Details
onchoice
expression
The callback expression to
execute in the controller when
the user (dis)likes an image.
This function takes the
following arguments:
ˆ image id - The image
ID of the image that
was (dis)liked.
ˆ choice - true if the
image was liked; false
if the image was
disliked.
needsmore
boolean
isdone
boolean
A boolean that indicates
whether more pictures will be
supplied.
A boolean that indicates
whether all pictures have been
displayed.
Parameters
Methods
ˆ finished()
This method is private.
Called when interest analysis is complete. Shows calculating image and text.
ˆ nextImage()
Sets a timer of 300ms to remove the current swipe image from the image buffer and enable the
next one.
ˆ onDrag()
This method is private.
Called on every step of a dragging motion on the swipe image.
ˆ onDragStart()
This method is private.
Initializes a dragging motion on the swipe image.
ˆ onDragStop()
This method is private.
Ends a dragging motion on the swipe image. If the image was dragged beyond 1/4th of the screen
or was dragged at a delta of 1/100th of the screen, it is swiped to the left or right depending on
its direction. If neither event occurred or both occurred in opposite directions, the swipe image
moves back to its initial position.
ˆ refresh()
Refreshes the current swipe image and background image with the first two images currently in
the image buffer.
48
TravelMatch
Detailed Design Document
ˆ swipe(choice)
Moves the current swipe image off the screen and retrieves the next image. If onchoice is
defined, it is called with the image ID of the first image in the image buffer and the choice
parameter.
If choice is true then the image is moved to the right; otherwise, it is moved to the left.
Parameters
Param
Type
Details
choice
boolean
true to indicate a like; false
to indicate a dislike.
A.12.3
ImageService
Provides methods for receiving images from the back end and recording choices in the back end.
Methods
ˆ acceptImages(data)
This method is private.
Accepts images from the back end server and filters out all invalid images. For every image,
the optimal size for this device’s screen is selected. This method selects the largest size that
is smaller than this device’s resolution; this is calculated by multiplying width by height. If no
suitable size could be found, the smallest possible size is selected instead.
Parameters
Param
Type
Details
data
Array.<Object>
An array of image objects with
multiple size objects, obtained
from the back end API.
Returns
Array.<Object>
An array of the chosen image objects, with the
following properties:
– id - The ID of the image.
– url - The URL of the chosen image size.
– width - The width of the chosen image
size, in pixels.
– height - The height of the chosen image
size, in pixels.
If no valid images were found, an empty array is
returned.
ˆ get(n)
Retrieves the specified number of images. The promise returned by this method is resolved if
the retrieval was successful or rejected with the translation ID of the error if the retrieval failed.
If the promise resolves, an object with following properties is passed:
49
TravelMatch
–
–
–
–
Detailed Design Document
id - The ID of the image.
url - The URL of the chosen image size.
width - The width of the chosen image size, in pixels.
height - The height of the chosen image size, in pixels.
Parameters
Param
Type
Details
n
(optional)
number
The amount of images to
retrieve. Must be at least 1
and at most 100. If out of
range, the closest value within
range is chosen instead.
(default: 1)
Returns
Promise
A promise of the image retrieval action that
ˆ httpError(deferred, data)
This method is private.
Rejects the provided deferred object with the matching translation ID of an error message based
on the HTTP status code received from the back end.
Parameters
Param
Type
Details
deferred
Object
data
Object
The deferred object received
from the caller.
The data received from the
back end.
ˆ httpSuccess(deferred, data, parser)
This method is private.
Parses the provided data with the provided parser function, then resolves the provided deferred
object with the parsed data.
Parameters
Param
Type
Details
deferred
Object
data
Object
parser
function
The deferred object received
from the caller.
The data received from the
back end.
The parser function to be
used to parse the data
received from the back end.
ˆ initial()
50
TravelMatch
Detailed Design Document
Retrieves the initial set of images for the specified vacation details.
Equivalent to calling get(5).
Returns
Promise
A promise of the image retrieval action that is
resolved if the retrieval was successful or
rejected with the translation ID of the error if
the retrieval failed.
ˆ next(imageId, like, isLast)
Posts the (dis)like choice of the current image to the back end and optionally retrieves the new
image. The promise returned by this method is resolved if the action was successful or rejected
with the translation ID of the error if the retrieval failed.
Parameters
Param
Type
Details
imageId
number
like
boolean
isLast
(optional)
boolean
The ID of the image that was
(dis)liked.
true if the user liked the
specified image; otherwise,
false.
If true, this method will not
retrieve any new images.
(default: false)
Returns
Promise
A.13
A promise of the choice post and image
retrieval action.
app.user.details
The app.user.details module contains all templates, controllers and services that pertain to the
user details screen.
A.13.1
UserDetailCtrl
The AngularJS controller for the user details screen.
Methods
ˆ save()
Posts the current values of the user data input fields to the back end. If the post fails, an error
pop-up is shown; otherwise, a success pop-up is shown and afterwards the user is transferred to
the interest analysis screen.
Properties
ˆ info
51
TravelMatch
Detailed Design Document
The model for the user info input fields, with the following properties:
– name - string - The name of the user.
– gender - string - The gender of the user. Can be one of the following values:
* none
* male
* female
– birthday - Date - The birth date of the user.
Type: Object
A.13.2
UserDetailsService
Provides methods for getting and setting the user info from the back end.
Methods
ˆ get()
Gets the user info from the back server. The promise returned by this method is resolved if the
retrieval was successful or rejected with the translation ID of the error if the retrieval failed. If
the promise resolves, an object with the following properties is passed:
– name - string - The name of the user.
– gender - string - The gender of the user. Can be one of the following values:
* none
* male
* female
– birthday - Date - The birth date of the user.
Returns
Promise
A promise of the user info get action.
ˆ put(info)
Puts the user data on the back end service. The promise returned by this method is resolved if
the storage was successful or rejected with the translation ID of the error if the storage failed.
Parameters
52
TravelMatch
Detailed Design Document
Param
Type
Details
info
Object
A user info object with the
following optional properties:
– name - string - The
name of the user.
– gender - string - The
gender of the user. Can
be one of the following
values:
* none
* male
* female
– birthday - Date - The
birth date of the user.
Returns
Promise
A promise of the user info put action.
53
TravelMatch
Detailed Design Document
Appendix B
Back end documentation
B.1
Documentation template
Each object in the back end documentation is documented with the following template:
Name of class
A description of the class, with an inheritance diagram.
Public Member Functions (if applicable)
ˆ def functionName (self, parameterName)
Description of the function.
Private Member Functions (if applicable)
ˆ def functionName (self, parameterName)
Description of the function.
Private Attributes (if applicable)
ˆ attribute name
Constructor & Destructor Documentation
def
init
(
self )
A description of the constructor.
Member Function Documentation (if applicable)
def function name ( self, parameter name,
) [private] A description of the function.
Parameters (if applicable)
parameter ←name
<parameter ←name>
optional ←parameter ←name
<optional ←parameter ←name>
optional parameter name = default value
A description of the parameter.
The type of the parameter.
A description of the optional parameter.
The type of the parameter.
54
TravelMatch
default value
Detailed Design Document
A description of the default value. Default: the default value.
Returns (if applicable)
The return type
Member Data Documentation (if applicable)
data name [private]
The documentation for this class was generated from the following file:
ˆ directory/file.py
B.2
affiliate
affiliate is a namespace that contains classes, variables and functions that relate to the affiliate
networks components. This namespace mainly acts as a container for several other namespaces, namely
those relating to the affiliate parsers, the models, serializers and views.
Namespaces
ˆ
ˆ
ˆ
ˆ
ˆ
affiliate parser
models
serializer
tradetracker
views
B.3
affiliate.affiliate parser
affiliate.affiliate parser is a namespace that contains classes, variables and functions that
relate to affiliate network parsers. This namespace contains an abstract parser, which can be extended
to parse feeds from any supported affiliate network. Extenders should define a parser name and set
up an entry mapping in the constructor to adapt the base parser to a specific feed.
Classes
ˆ class Parser
This class represents a parser object in affiliate.
B.3.1
Parser
This class represents a parser object in affiliate.
Inheritance diagram for Parser:
object
Parser
ArkeParser
55
TravelMatch
Detailed Design Document
Public Member Functions
ˆ def
init
(self)
Initialize all required dictionaries and lists.
ˆ def process single (self, feed url)
Processes a single url.
Private Member Functions
ˆ def store entry (self)
Stores all information inside the dictionaries inside the model.
ˆ def find and add all xml attributes (self, xml keys required, entry)
Finds the required xml variables using the xml-attribute syntax in the entry and stores their attribute
them in the dictionary.
ˆ def find and add all xml elements (self, xml keys required, entry)
Finds the required xml variables using the xml-elements syntax in the entry and stores their attribute
them in the dictionary.
ˆ def get root (self, feed url)
Opens a URL and returns the root of its elementTree.
ˆ def add entry
Adds an entry to the dictionaries of this object.
ˆ def check for discard (self)
Checks if the current entry should be discarded.
ˆ def get correct attribute value (self, model field name)
Gets the attribute value corresponding to the given model field name.
ˆ def get correct date format (self, date)
Make the format of the date as Django accepts.
ˆ def is rep ok (self)
Checks if all must have model variables have been initialized.
Private Attributes
ˆ
ˆ
ˆ
ˆ
model variables
must have model variables
model to attributes
xml to model
Detailed Description
This class represents a parser object in affiliate.
Constructor & Destructor Documentation
def
init
(
self )
Initialize all required dictionaries and lists.
Member Function Documentation
def add entry ( self, model field name, xml name, not found value = None ) [private]
Adds an entry to the dictionaries of this object.
The variables given in xml name will be sought for in the url and stored in the database at the
given model field variable.
56
TravelMatch
Detailed Design Document
Parameters
model field ←name
<model field←name>
xml name
<xml name>
not found ←value
The name of the model field variable.
basestring
The EXACT xml name inside the description. Input 'None' if value needs not to
be fetched from the XML feed.
basestring
Default value which is stored in the model when not found. Default: None.
Returns
Void
def check for discard ( self ) [private]
Checks if the current entry should be discarded.
This happens when a must have model variable was None (i.e. not found and no default).
Returns
Boolean whether the entry should be sicarded.
def find and add all xml attributes ( self, xml keys required, entry ) [private]
Finds the required xml variables using the xml-attribute syntax in the entry and stores their attribute
them in the dictionary.
Parameters
xml keys ←required
<xml keys ←required>
entry
<entry>
All XML keys whereof the attributes needs to be added.
String[]
An entry of the xml file which needs to be checked.
eTree
def find and add all xml elements ( self, xml keys required, entry ) [private]
Finds the required xml variables using the xml-elements syntax in the entry and stores their attribute
them in the dictionary.
Parameters
xml keys ←required
<xml keys ←required>
entry
<entry>
All XML keys whereof the attributes needs to be added.
String[]
An entry of the xml file which needs to be checked.
eTree
Finds all needed xml keys in the XML elements syntax and adds them to
the attributes ADT.
:param xml_keys_required: All XML keys whereof the attributes needs to be added.
:param entry: The entry to be checked.
:return: Void
57
TravelMatch
Detailed Design Document
def get correct attribute value ( self, model field name ) [private]
Gets the attribute value corresponding to the given model field name.
Contains extra input checking for inputs in the wrong format.
Parameters
model field ←name
<model field←name>
The variable name of the model field variable.
basestring
Returns
The corresponding attribute value of the model field name
Gets the attribute value corresponding to the given model_field_name.
:param model_field_name: The name of the model field variable.
:return: The corresponding attribute value.
def get correct date format ( self, date ) [private]
Make the format of the date as Django accepts.
Parameters
date
<date>
The date or datetime to be formalized in a correct format.
basestring
Returns
The date in a correct format.
Make the format of the date as Django wants.
:param date: The date (or datetime) to be formalized in a correct format.
:return: Returns date in the correct Django format.
def get root ( self, feed url ) [private]
Opens a URL and returns the root of its elementTree.
Parameters
feed url
<feed url>
The feed url which needs to be opened
URL
Returns
Root of the elementtree of the feed url.
Opens a URL and returns the root
def is rep ok ( self ) [private]
Checks if all must have model variables have been initialized.
def store entry ( self ) [private]
Stores all information inside the dictionaries inside the model.
Returns
A boolean whether it is was a success or failure.
def process single ( self, feed url ) Processes a single url.
The required data will be retrieved from the URL and stored in the database.
58
TravelMatch
Detailed Design Document
Parameters
feed url
<feed url>
The feed url which needs to be parsed.
URL
Returns
Void
Processes a single feed and makes a database entry.
:param feed_url: The feed url to be processed.
:return: Void
Member Data Documentation
model to attributes [private]
model variables [private]
must have model variables [private]
xml to model [private]
The documentation for this class was generated from the following file:
ˆ travelmatch/affiliate/affiliate parser.py
B.4
affiliate.models
affiliate.models is a namespace that contains classes, variables and functions that relate to the
affiliate network models. This namespace contains all the models for the retrieval and storage of affiliate
feeds, as well as the feeds and parsers themselves.
Classes
ˆ class AbstractParserModel
The abstract of a parser which can process a URL.
ˆ class AffiliateFeed
A feed consists of the url feed an a parser to process the url.
ˆ class ArkeParserModel
The specific parser for Arke.
ˆ class Trip
Represents a trip users can book.
Functions
ˆ def parse the feed (sender, instance=None, args, kwargs)
This method pass the feed to the parser.
Function Documentation
def affiliate.models.parse the feed (
method pass the feed to the parser.
sender,
59
instance = None,
args,
kwargs ) This
TravelMatch
Detailed Design Document
Parameters
instance
<instance>
sender
args
kwargs
The feed that needs to be parsed
object
not used
not used
not used
Precondition
instance is not None : instance being parsed
B.4.1
AbstractParserModel
The abstract of a parser which can process a URL.
Inheritance diagram for AbstractParserModel:
Model
AbstractParserModel
ArkeParserModel
Public Member Functions
ˆ def process single (self, url)
Processes the given URL and stores the info inside the URL into the database.
ˆ def
unicode
(self)
This method make sure the object is stored and retrieved in certain format:
ˆ def name (self)
Returns the name of the parser.
Static Public Attributes
ˆ tuple parser id = models.AutoField(primary key=True)
Private Member Functions
ˆ def get parser (self)
Detailed Description
The abstract of a parser which can process a URL.
Member Function Documentation
def unicode
format:
(
self ) This method make sure the object is stored and retrieved in certain
Returns
object in this format: u'Parser '+str(self.name())
60
TravelMatch
Detailed Design Document
def get parser (
def name (
self ) [private]
self ) Returns the name of the parser.
Returns
Name of the parser.
def process single ( self,
the database.
Parameters
url
<url>
url ) Processes the given URL and stores the info inside the URL into
The URL to be processed.
URL
Member Data Documentation
tuple parser id = models.AutoField(primary key=True) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/affiliate/models.py
B.4.2
AffiliateFeed
A feed consists of the url feed an a parser to process the url.
Inheritance diagram for AffiliateFeed:
Model
AffiliateFeed
Classes
ˆ class Meta
This enforce the combined super keys.
Public Member Functions
ˆ def parse (self)
Processes the contents of the URL and stores it inside the database.
Static Public Attributes
ˆ tuple url = models.URLField(max length=2048)
ˆ tuple parser = models.ForeignKey(ArkeParserModel, null=False)
ˆ tuple unique together = ((”url”, ”parser”),)
Detailed Description
A feed consists of the url feed an a parser to process the url.
61
TravelMatch
Detailed Design Document
Member Function Documentation
def parse (
self )
Processes the contents of the URL and stores it inside the database.
Member Data Documentation
tuple parser = models.ForeignKey(ArkeParserModel, null=False) [static]
tuple unique together = ((”url”, ”parser”),) [static]
tuple url = models.URLField(max length=2048) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/affiliate/models.py
B.4.3
AffiliateFeed.Meta
This enforce the combined super keys.
Detailed Description
This enforce the combined super keys.
The documentation for this class was generated from the following file:
ˆ travelmatch/affiliate/models.py
B.4.4
ArkeParserModel
The specific parser for Arke.
Inheritance diagram for ArkeParserModel:
Model
AbstractParserModel
ArkeParserModel
Private Member Functions
ˆ def get parser (self)
Additional Inherited Members
Detailed Description
The specific parser for Arke.
Member Function Documentation
def get parser ( self ) [private]
The documentation for this class was generated from the following file:
ˆ travelmatch/affiliate/models.py
62
TravelMatch
B.4.5
Detailed Design Document
Trip
Represents a trip users can book.
Inheritance diagram for Trip:
Model
Trip
Public Member Functions
ˆ def get must fields (self)
Returns the must-have field names as defined by our client.
ˆ def get fields (self)
Returns the field names of the model as a list.
ˆ def convert to trip offer (self)
This function convert an location to an Trip Offer object.
Static Public Attributes
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
name = models.CharField(max length=64)
description = models.TextField()
city = models.TextField()
region = models.TextField(null=True)
country = models.TextField(null=True)
hotel stars = models.IntegerField(null=True)
price = models.FloatField()
link = models.URLField()
image = models.URLField()
min nr people = models.IntegerField(null=True)
departure date = models.DateField()
duration = models.IntegerField()
with flight = models.TextField()
user rating = models.FloatField(null=True)
created on = models.DateTimeField(auto now add=True)
Detailed Description
Represents a trip users can book.
Parameters
name
<name>
description
<description>
The name of the accommodation.
String
A description of the destination.
String
63
TravelMatch
city
<city>
region
<region>
country
<country>
hotel stars
<hotel stars>
price
<price>
link
<link>
image
<image>
min nr people
<min nr ←people>
departure date
<departure ←date>
duration
<duration>
with flight
<with flight>
user rating
<user rating>
Detailed Design Document
The city of the trip.
String
The region of the trip.
String
The country of the trip.
String
The amount of stars the accommodation has
Integer
The price of the whole trip.
Float
An affiliate link to book the trip.
URL
An image of the trip.
Image
(Minimum) number of people for the trip.
Integer
The date of departure
Date
The duration of the trip.
Integer
Whether a flight is included with the trip.
Boolean
A user rating of the hotel
Float
Member Function Documentation
def convert to trip offer (
self )
This function convert an location to an Trip Offer object.
Returns
whether the conversion worked or not my offer.save(): The new Trip Offer object saved
def get fields (
self ) Returns the field names of the model as a list.
Returns
All field names of the model.
def get must fields (
self ) Returns the must-have field names as defined by our client.
Returns
All must-have field names of the model.
Member Data Documentation
tuple city = models.TextField() [static]
tuple country = models.TextField(null=True) [static]
64
TravelMatch
Detailed Design Document
tuple created on = models.DateTimeField(auto now add=True) [static]
tuple departure date = models.DateField() [static]
tuple description = models.TextField() [static]
tuple duration = models.IntegerField() [static]
tuple hotel stars = models.IntegerField(null=True) [static]
tuple image = models.URLField() [static]
tuple link = models.URLField() [static]
tuple min nr people = models.IntegerField(null=True) [static]
tuple name = models.CharField(max length=64) [static]
tuple price = models.FloatField() [static]
tuple region = models.TextField(null=True) [static]
tuple user rating = models.FloatField(null=True) [static]
tuple with flight = models.TextField() [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/affiliate/models.py
B.5
affiliate.serializer
affiliate.serializer is a namespace that contains classes, variables and functions that relate to
the affiliate network serializers. This namespace contains Django serializers, which verify and modify
the input and output of data in the model.
65
TravelMatch
B.6
Detailed Design Document
affiliate.tradetracker
affiliate.tradetracker is a namespace that contains classes, variables and functions that relate
to TradeTracker-specific affiliate network parsers. This namespace contains namespaces with classes
that extend the abstract parser in the affiliate.affiliate parser namespace to parse feeds from
TradeTracker.
Namespaces
ˆ arke parser
B.7
affiliate.tradetracker.arke parser
affiliate.tradetracker.arke parser is a namespace that contains classes, variables and functions that relate to ArkeFly-specific affiliate network parsers. This namespace contains the concrete
parser for ArkeFly from the TradeTracker affiliate network that extends the abstract parser in the
affiliate.affiliate parser namespace.
Classes
ˆ class ArkeParser
This is the specific parser for the Arke feed of TradeTracker.
B.7.1
ArkeParser
This is the specific parser for the Arke feed of TradeTracker.
Inheritance diagram for ArkeParser:
object
Parser
ArkeParser
Public Member Functions
ˆ def
init
(self)
Initializes all variables which needs to be found in the XML files.
Static Public Attributes
ˆ string parser name = ”Arke”
Detailed Description
This is the specific parser for the Arke feed of TradeTracker.
Constructor & Destructor Documentation
def
init ( self ) Initializes all variables which needs to be found in the XML files.
and stored inside the database.
66
TravelMatch
Detailed Design Document
Member Data Documentation
string parser name = ”Arke” [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/affiliate/tradetracker/arke parser.py
B.8
affiliate.views
affiliate.views is a namespace that contains classes, variables and functions that relate to the
affiliate network views. This namespace would contain Django view controllers for managing the
affiliate network feeds; however, as no Django view controllers are required, this namespace is left
empty.
B.9
ai
ai is a namespace that contains classes, variables and functions that relate to the artificial intelligence
components. This namespace mainly acts as a container for several other namespaces, namely those
relating to the entropy calculation, the recommender system, the models, serializers and views.
Namespaces
ˆ
ˆ
ˆ
ˆ
ˆ
entropy
models
recommender system
serializers
views
B.10
ai.entropy
ai.entropy is a namespace that contains classes, variables and functions that relate to the entropy
calculation. This namespace contains the functions which retrieves the next images based on a selfdefined entropy value of that image. These images are then shown to the user in the interest analysis
to maximize the information gain for the Travel DNA. It also stores a blacklist from the images which
should not be recommended as well as keeps track of the entropy score of the user.
Functions
ˆ def calculate next images (entropy input, number of images to load, vacation)
The function that calclulates the next n recommended images to send to the user from some travel←DNA.
ˆ def initialize vacation tags (vacation)
Initializes all vacation tags to 0.
ˆ def get entropy data (vacation)
Returns the entropy data that is stored inside vacation tag.
ˆ def add to blacklist (image object, vacation)
Adds an image to the blacklist.
ˆ def purge blacklist (vacation)
Removes all elements from the blacklist.
ˆ def get first n random (number of images to load, vacation)
Returns n random images which are not in the blacklist.
67
TravelMatch
Detailed Design Document
ˆ def get best tag (user entropy data)
Returns the tag with the lowest score >> the best priority.
ˆ def get best image (tag id, forbidden images)
Returns the best image object with the highest potential score for this tag >> the highest tag val
sum.
ˆ def get best tags on total score (tag dict)
Returns a list of tags with the lowest total potential score.
ˆ def get images sorted on best tag val (given tag id, forbidden images)
Returns a list of images based on the highest value for the given tag id.
ˆ def get best tags on priority (tag id list)
Returns a list of tags with the lowest priority value (= best priority).
ˆ def get best image on max sum values (best images list)
Returns a list of images with the largest sum value for its tags.
Function Documentation
def ai.entropy. add to blacklist (
Adds an image to the blacklist.
Parameters
image object
vacation
<vacation>
image object,
vacation ) [private]
The image object to add
The vacation id of the vacation
int
def ai.entropy. get best image ( tag id, forbidden images ) [private]
Returns the best image object with the highest potential score for this tag >> the highest tag val
sum.
Parameters
tag id
forbidden ←images
The tag id to try to maximize on
the input image lists
Returns
best image The image with the highest entropy potential
def ai.entropy. get best image on max sum values ( best images list ) [private]
Returns a list of images with the largest sum value for its tags.
Parameters
best images
←-
A list of Image objects to filter upon
list
Returns
A list of Image objects with the highest sum for their tag values
def ai.entropy. get best tag ( user entropy data ) [private]
Returns the tag with the lowest score >> the best priority.
68
TravelMatch
Detailed Design Document
Parameters
user entropy←data
A dictionary consisting of {img id: img total pot value}
Returns
tag id of the best tag
def ai.entropy. get best tags on priority ( tag id list ) [private]
Returns a list of tags with the lowest priority value (= best priority).
Parameters
tag id list
A list of tag ids
Returns
List of tag ids with the lowest priority value.
def ai.entropy. get best tags on total score ( tag dict ) [private]
Returns a list of tags with the lowest total potential score.
Parameters
tag dict
A dictionary containing {tag id: total potential score} for all tag ids
Returns
Dictionary containing top 1 {tag id: total potential score} with the possible lowest total
potential score (returns multiple if tied).
←-
def ai.entropy. get entropy data ( vacation ) [private]
Returns the entropy data that is stored inside vacation tag.
Parameters
vacation
<vacation>
The vacation id of the vacation
int
Returns
Dictionary with {tag id: total pot value} for all tag id in Tag.objects.all()
given tag id,
def ai.entropy. get images sorted on best tag val (
[private]
Returns a list of images based on the highest value for the given tag id.
Parameters
given tag id
forbidden ←images
The tag id to search an image on
the input image lists
Returns
List of image objects
def ai.entropy. initialize vacation tags (
Initializes all vacation tags to 0.
vacation ) [private]
69
forbidden images
)
TravelMatch
Detailed Design Document
Parameters
vacation
<vacation>
The vacation id of the vacation
int
def ai.entropy. purge blacklist ( vacation ) [private]
Removes all elements from the blacklist.
Parameters
vacation
<vacation>
The vacation id of the vacation
int
def ai.entropy.calculate next images ( entropy input, number of images to load, vacation
) The function that calclulates the next n recommended images to send to the user from some
travelDNA.
It bases this calculation on the entropy loss for each image. The user input consists of a array of
likings and disliking with the according tagvalues. So it consists of [ {'like': True, 0: val0, 1: val1,
2: val2, .., n: valn}, ... ] where the 'like' key is a boolean that represents a liking. The 0 to n keys
are the id's of all n active tags in the database with their corresponding values for the image that was
liked/disliked. If no value was given for a tag the value is set to 0.
Precondition
0 <= val <= 100 for all values
1 <= n <= 100
all active tag ids in the database are in the dictonary
Parameters
entropy input
number of ←images to load
<number of ←images to ←load>
vacation
<vacation>
[ {'like': True, 0: val0, 1: val1, 2: val2, .., n: valn}, ..., ]
the number of images that are requested
int
the input vacation
VacationDetails
Returns
an array of image objects of length n. When it cannot find n images, less (or zero) image objects
can be returned
def ai.entropy.get first n random ( number of images to load, vacation ) Returns n random
images which are not in the blacklist.
Parameters
number of ←images to load
the number of images that are requested
70
TravelMatch
<number of ←images to ←load>
vacation
vacation
Detailed Design Document
int
The vacation id of the iser
int
Returns
List of 5 random non-duplicate image objects.
B.11
ai.models
ai.models is a namespace that contains classes, variables and functions that relate to the artificial
intelligence models. This namespace contains all Django models related to artificial intelligence, which
includes swipe images and their attributes, locations, all type of tags, Travel DNAs, and data required
for AI calcuation such as the image and location blacklists.
Classes
ˆ class ImageBlacklistItem
This class is for the image blacklist item object.
ˆ class ImageDimension
This represents all the image dimensions database support.
ˆ class ImageTag
This represents the tag for images.
ˆ class Location
The locations the Travelmatch supports.
ˆ class LocationBlacklistItem
This class is for the lovation blacklist item object.
ˆ class LocationTag
This represents the tag for locations.
ˆ class SwipeImage
The images user relieve to swipe.
ˆ class Tag
This class represents the tag object either for images or locations.
ˆ class TravelDNA
This stores the Travel DNA of the user.
ˆ class TripOffer
This represents the offer of trip.
ˆ class VacationTag
This represnts the vacation tag object.
Functions
ˆ def get max abs price (budget)
Does the budget filtering.
ˆ def create
< activation status, for versioning
ˆ def
unicode
(self)
Returns the SwipeImage object in certain format.
71
TravelMatch
Detailed Design Document
ˆ def get file loc (self, image dimension)
Return the file location of this image for each dimension to get the abs path (/var/www/media/swipe←images/test-photo-1 1080x1920.jpg) you use MEDIA ROOT + get file loc().
ˆ def get abs file loc (self, image dimension)
ˆ def get file url (self, image dimension)
ˆ def get all file dimension instaces in folder (self)
This method returns all the instance within the iamge folder.
ˆ def remove all file instances (self)
This method remove all swipe image file in the folder os.remove(file) all the files in the swipe image
folder gets removed.
ˆ def force create file instances (self, image dimensions)
Create all the different versions of an image with the specified image dimensions.
ˆ def update file instances (self, image dimensions)
This method update all the swipe image files and adapt them to the given image dimensions.
ˆ def has all file instances (self, image dimensions)
This method check whether the swipe image was converted to image dimensions or not.
ˆ def create json response (self)
Creates the json response in a python dict as specified in the API (GET: /user/swipe)
ˆ def img html tag (self)
returning a string containing image's resolution and url
ˆ def create missing tags (self, new tags)
Creates any missing tag values.
ˆ def activate image (self)
This function activate the swipe image self.active=True: activation of the swipe image.
ˆ def deactivate image (self)
This function deactivate the swipe image self.active=False: deactivation of the swipe image.
ˆ def update images dimension (sender, instance=None, args, kwargs)
This function adapts the SwipeImage object into the dimensions in the database.
ˆ def create missing tags (sender, instance=None, args, kwargs)
This function creates the needed LocationTags when creating a new location.
Variables
ˆ tuple img id = models.AutoField(primary key=True)
ˆ tuple created = models.DateTimeField(auto now add=True)
< id of the image (primary key) (integer)
ˆ tuple uploaded by = models.ForeignKey(User)
< date image being uploaded (integer)
ˆ tuple original filename = models.ImageField(upload to='swipe images')
< the admin user added the image (admin user id)
ˆ tuple active = models.BooleanField(null=False, default=True)
< the image (ImageField)
Function Documentation
def ai.models. unicode
(
self )
Returns the SwipeImage object in certain format.
Returns
Tag u'Image s: s' % (self.img id, self.original filename)
72
TravelMatch
Detailed Design Document
def ai.models.activate image (
activation of the swipe image.
self ) This function activate the swipe image self.active=True:
def ai.models.create ( self, force insert = False, force update = False,
update fields = None ) < activation status, for versioning
creating a new tag tuple (not update, just create)
using = None,
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def ai.models.create json response ( self )
in the API (GET: /user/swipe)
Creates the json response in a python dict as specified
Returns
json: json object containing image dimensions and size
def ai.models.create missing tags (
Parameters
new tags
self,
new tags )
Creates any missing tag values.
all the Tag objects to create if needed
def ai.models.create missing tags ( sender, instance = None,
function creates the needed LocationTags when creating a new location.
args,
kwargs ) This
Precondition
None
Parameters
sender
instance
args
kwargs
input images
not used
not used Location: Location.create missing tags
def ai.models.deactivate image (
self ) This function deactivate the swipe image self.←active=False: deactivation of the swipe image.
def ai.models.force create file instances ( self, image dimensions ) Create all the different
versions of an image with the specified image dimensions.
73
TravelMatch
Detailed Design Document
Parameters
image ←dimensions
ImageDimensions
Returns
image: image with image dimensions
def ai.models.get abs file loc (
self,
image dimension )
See also
get file loc
def ai.models.get all file dimension instaces in folder (
instance within the iamge folder.
self ) This method returns all the
Returns
[SwipeImages]: all swipe images in the image folder
def ai.models.get file loc ( self, image dimension ) Return the file location of this image
for each dimension to get the abs path (/var/www/media/swipe images/test-photo-1 1080x1920.jpg)
you use MEDIA ROOT + get file loc().
To get the abs url use BASE URL+MEDIA URL + get file loc().
Returns
string: filename +
+ dimension.to x() + .jpg
def ai.models.get file url (
self,
image dimension )
See also
get file loc
def ai.models.get max abs price (
Parameters
budget
budget )
Does the budget filtering.
the budget saved in the location details (in cents) (int)
Returns
the budget margin for which offers can be retrieved (in euros)
def ai.models.has all file instances ( self, image dimensions ) This method check whether
the swipe image was converted to image dimensions or not.
Parameters
image ←dimensions
<image ←dimensions>
the image dimensions you wish to check
[ImageDimension]
Returns
boolean value whether the swipe image was converted to image dimensions or not
74
TravelMatch
Detailed Design Document
def ai.models.img html tag (
self ) returning a string containing image's resolution and url
Returns
string: '' % (url, resolution[0].width, resolution[0].height)
def ai.models.remove all file instances ( self ) This method remove all swipe image file in the
folder os.remove(file) all the files in the swipe image folder gets removed.
def ai.models.update file instances ( self, image dimensions ) This method update all the
swipe image files and adapt them to the given image dimensions.
Parameters
image ←dimensions
<image ←dimensions>;
the image dimensions you wish to have
[ImageDimension]
Returns
Boolean whether the images are updated or not SwipeImages updated according to the image
dimensions
def ai.models.update images dimension ( sender, instance = None, args, kwargs ) This
function adapts the SwipeImage object into the dimensions in the database.
Precondition
None
Parameters
sender
instance
args
kwargs
input images
not used
not used SwipeImage: SwipeImage.update images dimension
Variable Documentation
active = models.BooleanField(null=False, default=True) < the image (ImageField)
tuple created = models.DateTimeField(auto now add=True)
(integer)
< id of the image (primary key)
tuple img id = models.AutoField(primary key=True)
tuple original filename = models.ImageField(upload to='swipe images') < the admin user
added the image (admin user id)
tuple uploaded by = models.ForeignKey(User)
75
< date image being uploaded (integer)
TravelMatch
B.11.1
Detailed Design Document
ImageBlacklistItem
This class is for the image blacklist item object.
Inheritance diagram for ImageBlacklistItem:
Model
ImageBlacklistItem
Classes
ˆ class Meta
< date the tag is added (Datefield)
Public Member Functions
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def remove (self)
This function removes object from the database the BlacklistItem with vac && img is deleted.
Static Public Attributes
ˆ tuple img = models.ForeignKey(SwipeImage, null=False)
ˆ tuple vac = models.ForeignKey('appusers.VacationDetail', null=False)
< the image of the image blacklist object (SwipeImage)
ˆ tuple created on = models.DateTimeField(auto now add=True)
< the vacation of the image blacklist object (VacationDetails)
Detailed Description
This class is for the image blacklist item object.
Member Function Documentation
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
76
using = None,
update←-
TravelMatch
Detailed Design Document
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def remove ( self )
&& img is deleted.
This function removes object from the database the BlacklistItem with vac
Member Data Documentation
tuple created on = models.DateTimeField(auto now add=True) [static]
< the vacation of the image blacklist object (VacationDetails)
tuple img = models.ForeignKey(SwipeImage, null=False) [static]
tuple vac = models.ForeignKey('appusers.VacationDetail', null=False) [static]
< the image of the image blacklist object (SwipeImage)
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.2
ImageBlacklistItem.Meta
< date the tag is added (Datefield)
Static Public Attributes
ˆ tuple unique together = ((”img”, ”vac”), )
Detailed Description
< date the tag is added (Datefield)
This makes ( img && vacation ) a super key
Member Data Documentation
tuple unique together = ((”img”, ”vac”), ) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.3
ImageDimension
This represents all the image dimensions database support.
Inheritance diagram for ImageDimension:
Model
ImageDimension
77
TravelMatch
Detailed Design Document
Classes
ˆ class Meta
< This is the height of the image (int)
Public Member Functions
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def
unicode
(self)
This returns the ImageDimensions with certain format in a string.
ˆ def to x (self)
This returns the ImageDimensions with certain format in a string.
Static Public Member Functions
ˆ def get all ()
This returns all the ImageDimensions objects in the database.
Static Public Attributes
ˆ tuple width = models.IntegerField(null=False, blank=False)
ˆ tuple height = models.IntegerField(null=False, blank=False)
< This is the width of the image (int)
Detailed Description
This represents all the image dimensions database support.
Member Function Documentation
def
unicode
(
self )
This returns the ImageDimensions with certain format in a string.
Returns
string: u''+self.to x()
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
78
using = None,
update←-
TravelMatch
Detailed Design Document
def get all ( ) [static]
This returns all the ImageDimensions objects in the database.
Returns
all ImageDimensions objects
def to x (
self ) This returns the ImageDimensions with certain format in a string.
Returns
string: str(self.width) + ”x” + str(self.height)
Member Data Documentation
tuple height = models.IntegerField(null=False, blank=False) [static]
< This is the width of the image (int)
tuple width = models.IntegerField(null=False, blank=False) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.4
ImageDimension.Meta
< This is the height of the image (int)
Static Public Attributes
ˆ tuple unique together = ((”width”, ”height”),)
Detailed Description
< This is the height of the image (int)
This makes (width&&height) a super key
Member Data Documentation
tuple unique together = ((”width”, ”height”),) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.5
ImageTag
This represents the tag for images.
Inheritance diagram for ImageTag:
Model
ImageTag
Classes
ˆ class Meta
< the value of the image tag (int)
79
TravelMatch
Detailed Design Document
Public Member Functions
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def save (self, args, kwargs)
This method override the save function from django and ensures that every object is unique.
Public Attributes
ˆ pk
Static Public Attributes
ˆ tuple img = models.ForeignKey(SwipeImage, null=False)
ˆ tuple tag = models.ForeignKey(Tag, null=False)
< the image of the image tag (SwipeImage)
ˆ tuple value = models.IntegerField(null=False, blank=True, default=0)
< the tag of the image tag (Tag)
ˆ tuple unique together = ((”img”, ”tag”),)
Detailed Description
This represents the tag for images.
Member Function Documentation
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
using = None,
update←-
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def save ( self, args, kwargs )
ensures that every object is unique.
This method override the save function from django and
Member Data Documentation
tuple img = models.ForeignKey(SwipeImage, null=False) [static]
pk
80
TravelMatch
Detailed Design Document
tuple tag = models.ForeignKey(Tag, null=False) [static]
< the image of the image tag (SwipeImage)
tuple unique together = ((”img”, ”tag”),) [static]
tuple value = models.IntegerField(null=False, blank=True, default=0) [static]
< the tag of the image tag (Tag)
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.6
ImageTag.Meta
< the value of the image tag (int)
Detailed Description
< the value of the image tag (int)
This makes (img && tag) a super key
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.7
Location
The locations the Travelmatch supports.
Inheritance diagram for Location:
Model
Location
Public Member Functions
ˆ def create
< versioned or not for versioning purposes (boolean)
ˆ def
unicode
(self)
This function enforce certain format on object output return object with certain format u'Location
s: s' % (self.loc id, self.city name)
ˆ def generate hotels offer (self, vac)
Generates hotel id's for the location overview.
ˆ def create missing tags (self, tags)
Creates any missing tag values.
ˆ def activate location (self)
This function activate the location self.active=True: activation of the swipe image.
ˆ def deactivate location (self)
This function deactivate the location self.active=False: deactivation of the swipe image.
81
TravelMatch
Detailed Design Document
Public Attributes
ˆ active
Static Public Attributes
ˆ tuple loc id = models.AutoField(primary key=True)
ˆ tuple city name = models.CharField(max length=64, null=False, blank=False)
< id(primary key) of the location (integer)
ˆ tuple country name = models.CharField(max length=64, null=False, blank=True, default=””)
< the name of the city of the location (string)
ˆ tuple region name = models.CharField(max length=64, null=False, blank=True, default=””)
< the country of the location (string)
ˆ tuple active = models.BooleanField(null=False, default=True)
< the region of the location (string)
Detailed Description
The locations the Travelmatch supports.
Member Function Documentation
def unicode ( self ) This function enforce certain format on object output return object with
certain format u'Location s: s' % (self.loc id, self.city name)
def activate location (
the swipe image.
self ) This function activate the location self.active=True: activation of
def create ( self, force insert = False, force update = False, using = None,
fields = None ) < versioned or not for versioning purposes (boolean)
creating a new tag tuple (not update, just create)
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def create missing tags (
Parameters
self,
tags ) Creates any missing tag values.
82
update←-
TravelMatch
Detailed Design Document
tags
all the Tag objects to create if needed
def deactivate location (
vation of the swipe image.
def generate hotels offer (
Parameters
vac
self ) This function deactivate the location self.active=False: deacti-
self,
vac ) Generates hotel id's for the location overview.
The vacationdetails for wich the hotel overview must be
Returns
list: an array of hotelOffer instances
Member Data Documentation
tuple active = models.BooleanField(null=False, default=True) [static]
< the region of the location (string)
active
tuple city name = models.CharField(max length=64, null=False, blank=False) [static]
< id(primary key) of the location (integer)
tuple country name = models.CharField(max length=64, null=False, blank=True, default=””)
[static]
< the name of the city of the location (string)
tuple loc id = models.AutoField(primary key=True) [static]
tuple region name = models.CharField(max length=64, null=False, blank=True, default=””)
[static]
< the country of the location (string)
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.8
LocationBlacklistItem
This class is for the lovation blacklist item object.
Inheritance diagram for LocationBlacklistItem:
Model
LocationBlacklistItem
Classes
ˆ class Meta
< the vacation of the image blacklist object (VacationDetails)
83
TravelMatch
Detailed Design Document
Public Member Functions
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def remove (self)
This function removes object from the database the LocationBlacklistItem with vac && img is
deleted.
Static Public Attributes
ˆ tuple loc = models.ForeignKey(Location, null=False)
ˆ tuple vac = models.ForeignKey('appusers.VacationDetail', null=False)
Detailed Description
This class is for the lovation blacklist item object.
Member Function Documentation
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
using = None,
update←-
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new object
def remove ( self ) This function removes object from the database the LocationBlacklistItem
with vac && img is deleted.
Member Data Documentation
tuple loc = models.ForeignKey(Location, null=False) [static]
tuple vac = models.ForeignKey('appusers.VacationDetail', null=False) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.9
LocationBlacklistItem.Meta
< the vacation of the image blacklist object (VacationDetails)
Static Public Attributes
ˆ tuple unique together = ((”loc”, ”vac”), )
84
TravelMatch
Detailed Design Document
Detailed Description
< the vacation of the image blacklist object (VacationDetails)
This makes ( img && vacation ) a super key
Member Data Documentation
tuple unique together = ((”loc”, ”vac”), ) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.10
LocationTag
This represents the tag for locations.
Inheritance diagram for LocationTag:
Model
LocationTag
Classes
ˆ class Meta
This makes (tag id && loc id) a super key.
Public Member Functions
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def save (self, args, kwargs)
This method override the save function from django and ensures that every object is unique.
Static Public Member Functions
ˆ def put (tag id, loc id, value, initial value)
This save the new location tag, or upgrade it if it exist.
Public Attributes
ˆ pk
ˆ value
Static Public Attributes
ˆ tuple tag id = models.ForeignKey(Tag, null=False)
ˆ tuple loc id = models.ForeignKey(Location, null=False)
< tag of location tag (Tag)
ˆ tuple value = models.IntegerField(null=False, blank=True, default=0)
< location of location tag (Location)
ˆ tuple initial value = models.IntegerField(null=False, default=0)
< value of the location tag (integer)
85
TravelMatch
Detailed Design Document
ˆ tuple last modified by = models.ForeignKey(User, null=True)
ˆ tuple unique together = ((”tag id”, ”loc id”),)
Detailed Description
This represents the tag for locations.
Member Function Documentation
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
using = None,
update←-
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def put ( tag id, loc id, value, initial value ) [static]
This save the new location tag, or upgrade it if it exist.
Parameters
tag id
<tag id>
loc id
<loc id>
value
<value>
initial value
<initial ←value>
the
int
the
int
the
int
the
int
id of the input tag
input id of the location
input value of the tag
initial value of the input tag
Returns
new tag with the parameters iff. the tag does not exist, else update and return the exist tag new
Tag object
def save ( self, args, kwargs )
ensures that every object is unique.
This method override the save function from django and
Member Data Documentation
tuple initial value = models.IntegerField(null=False, default=0) [static]
< value of the location tag (integer)
tuple last modified by = models.ForeignKey(User, null=True) [static]
86
TravelMatch
Detailed Design Document
tuple loc id = models.ForeignKey(Location, null=False) [static]
< tag of location tag (Tag)
pk
tuple tag id = models.ForeignKey(Tag, null=False) [static]
tuple unique together = ((”tag id”, ”loc id”),) [static]
tuple value = models.IntegerField(null=False, blank=True, default=0) [static]
< location of location tag (Location)
value
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.11
LocationTag.Meta
This makes (tag id && loc id) a super key.
Detailed Description
This makes (tag id && loc id) a super key.
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.12
SwipeImage
The images user relieve to swipe.
Inheritance diagram for SwipeImage:
Model
SwipeImage
Detailed Description
The images user relieve to swipe.
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
87
TravelMatch
B.11.13
Detailed Design Document
Tag
This class represents the tag object either for images or locations.
Inheritance diagram for Tag:
Model
Tag
Classes
ˆ class Meta
< prioritizeing the tags for undecided cases, lower number has a higher priority (integer)
Public Member Functions
ˆ def
unicode
(self)
< the index for ordering/sorting tag objects in the database
ˆ def create
creating a new tag tuple (not update, just create)
Static Public Attributes
ˆ tuple tag id = models.AutoField(primary key=True)
ˆ tuple name = models.CharField(max length=256, null=False, blank=False)
< the id(primary key) of the tag (integer)
ˆ tuple created on = models.DateTimeField(auto now add=True)
< the name of the tag (string)
ˆ tuple created by = models.ForeignKey(User)
< date the tag is added (Datefield)
ˆ tuple active = models.BooleanField(null=False, default=False)
< django admin users (integer)
ˆ tuple priority = models.IntegerField(null=False, default=100)
< versioned or not for versioning purposes (boolean)
ˆ string verbose name = ”Tag”
ˆ tuple ordering = ('created on',)
< human readable name
Detailed Description
This class represents the tag object either for images or locations.
Member Function Documentation
def
unicode ( self ) < the index for ordering/sorting tag objects in the database
representation for the Tag object
Returns
Tag object with specific format: ”u'Tag tag id, name, created on”
88
TravelMatch
Detailed Design Document
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
using = None,
update←-
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
Member Data Documentation
tuple active = models.BooleanField(null=False, default=False) [static]
< django admin users (integer)
tuple created by = models.ForeignKey(User) [static]
< date the tag is added (Datefield)
tuple created on = models.DateTimeField(auto now add=True) [static]
< the name of the tag (string)
tuple name = models.CharField(max length=256, null=False, blank=False) [static]
< the id(primary key) of the tag (integer)
tuple ordering = ('created on',) [static]
< human readable name
tuple priority = models.IntegerField(null=False, default=100) [static]
< versioned or not for versioning purposes (boolean)
tuple tag id = models.AutoField(primary key=True) [static]
string verbose name = ”Tag” [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.14
Tag.Meta
< prioritizeing the tags for undecided cases, lower number has a higher priority (integer)
Detailed Description
< prioritizeing the tags for undecided cases, lower number has a higher priority (integer)
Meta specify the human-readable name and ordering of the code
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
89
TravelMatch
B.11.15
Detailed Design Document
TravelDNA
This stores the Travel DNA of the user.
Inheritance diagram for TravelDNA:
Model
TravelDNA
Classes
ˆ class Meta
< boolean value see if the user likes it or not
Public Member Functions
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def display img filename (self)
This is for returning the image file name attribute.
ˆ def user (self)
This is for returning the user of the vacation.
ˆ def display img id (self)
This is for returning the img id of the image.
ˆ def vac id (self)
This is for returning the vac id of the vacation.
ˆ def display vac (self)
This is for calling the display function on the vacation from the Vacation class in AppUser.
ˆ def display user (self)
This is for calling the display function on the vacation from the AppUser class in AppUser.
Static Public Attributes
ˆ tuple img = models.ForeignKey(SwipeImage, null=False)
ˆ tuple vacation = models.ForeignKey('appusers.VacationDetail', null=False)
< the image of the TravelDNA object (SwipeImage)
ˆ tuple like = models.BooleanField(null=False)
< the vacation of the TravelDNA object (VacationDetails)
Detailed Description
This stores the Travel DNA of the user.
Member Function Documentation
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
90
using = None,
update←-
TravelMatch
Detailed Design Document
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def display img filename (
self ) This is for returning the image file name attribute.
Precondition
: None
Postcondition
print the image file name
Returns
the image file name
def display img id (
self ) This is for returning the img id of the image.
Precondition
None
Postcondition
None
Returns
the img id of the image
def display user ( self ) This is for calling the display function on the vacation from the AppUser
class in AppUser.
Precondition
None
Postcondition
None
Returns
display() for the user of the vacation of the travelDNA
91
TravelMatch
Detailed Design Document
def display vac (
class in AppUser.
self ) This is for calling the display function on the vacation from the Vacation
Precondition
None
Postcondition
None
Returns
display() for the vacation of the travelDNA
def user (
self ) This is for returning the user of the vacation.
Precondition
None
Postcondition
None
Returns
user related to the vacation
def vac id (
self ) This is for returning the vac id of the vacation.
Precondition
None
Postcondition
None
Returns
the vac id of the vacation
Member Data Documentation
tuple img = models.ForeignKey(SwipeImage, null=False) [static]
tuple like = models.BooleanField(null=False) [static]
< the vacation of the TravelDNA object (VacationDetails)
tuple vacation = models.ForeignKey('appusers.VacationDetail', null=False) [static]
< the image of the TravelDNA object (SwipeImage)
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
92
TravelMatch
B.11.16
Detailed Design Document
TravelDNA.Meta
< boolean value see if the user likes it or not
Static Public Attributes
ˆ tuple unique together = ((”img”, ”vacation”), )
Detailed Description
< boolean value see if the user likes it or not
This makes ( img && vacation ) a super key
Member Data Documentation
tuple unique together = ((”img”, ”vacation”), ) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.17
TripOffer
This represents the offer of trip.
Inheritance diagram for TripOffer:
Model
TripOffer
Classes
ˆ class Meta
This makes a lable for this TripOffer class.
Public Member Functions
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def generate json response (self)
this function generates json response from TripOffSerilaizer return the json response data
Static Public Attributes
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
ˆ
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
tuple
offer id = models.AutoField(primary key=True)
loc = models.ForeignKey(Location)
name = models.CharField(max length=64, null=False, blank=False)
description = models.TextField()
hotel stars = models.IntegerField(null=True, blank=True, default=None)
price = models.FloatField(null=False, blank=False)
link = models.URLField(null=False, blank=False)
image = models.URLField(null=False, blank=False)
min people = models.IntegerField(null=True, blank=True, default=None)
93
TravelMatch
ˆ
ˆ
ˆ
ˆ
ˆ
tuple
tuple
tuple
tuple
tuple
Detailed Design Document
dept date = models.DateField(null=False, blank=False)
duration days = models.IntegerField(null=False, blank=False)
with flight = models.BooleanField(null=False, blank=False, default=False)
user rating = models.FloatField(null=True, blank=True, default=None)
priority = models.IntegerField(null=False, blank=True, default=100)
Detailed Description
This represents the offer of trip.
Member Function Documentation
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
using = None,
update←-
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def generate json response (
return the json response data
self ) this function generates json response from TripOffSerilaizer
Member Data Documentation
tuple dept date = models.DateField(null=False, blank=False) [static]
tuple description = models.TextField() [static]
tuple duration days = models.IntegerField(null=False, blank=False) [static]
tuple hotel stars = models.IntegerField(null=True, blank=True, default=None) [static]
tuple image = models.URLField(null=False, blank=False) [static]
tuple link = models.URLField(null=False, blank=False) [static]
tuple loc = models.ForeignKey(Location) [static]
94
TravelMatch
Detailed Design Document
tuple min people = models.IntegerField(null=True, blank=True, default=None) [static]
tuple name = models.CharField(max length=64, null=False, blank=False) [static]
tuple offer id = models.AutoField(primary key=True) [static]
tuple price = models.FloatField(null=False, blank=False) [static]
tuple priority = models.IntegerField(null=False, blank=True, default=100) [static]
tuple user rating = models.FloatField(null=True, blank=True, default=None) [static]
tuple with flight = models.BooleanField(null=False, blank=False, default=False) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.18
TripOffer.Meta
This makes a lable for this TripOffer class.
Static Public Attributes
ˆ string app label = 'affiliate'
Detailed Description
This makes a lable for this TripOffer class.
Member Data Documentation
string app label = 'affiliate' [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.19
VacationTag
This represnts the vacation tag object.
Inheritance diagram for VacationTag:
Model
VacationTag
95
TravelMatch
Detailed Design Document
Classes
ˆ class Meta
This makes ( img && vacation ) a super key.
Public Member Functions
ˆ def remove (self)
This function removes object from the database the LocationBlacklistItem with vac && img is
deleted.
Static Public Attributes
ˆ tuple vac = models.ForeignKey('appusers.VacationDetail', null=False)
ˆ tuple tag = models.ForeignKey(Tag, null=False)
< the vacation of the image blacklist object (VacationDetails)
ˆ tuple sum value = models.IntegerField(null=False, blank=True, default=0)
Detailed Description
This represnts the vacation tag object.
Member Function Documentation
def remove ( self ) This function removes object from the database the LocationBlacklistItem
with vac && img is deleted.
Member Data Documentation
tuple sum value = models.IntegerField(null=False, blank=True, default=0) [static]
tuple tag = models.ForeignKey(Tag, null=False) [static]
< the vacation of the image blacklist object (VacationDetails)
tuple vac = models.ForeignKey('appusers.VacationDetail', null=False) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
B.11.20
VacationTag.Meta
This makes ( img && vacation ) a super key.
Static Public Attributes
ˆ tuple unique together = ((”vac”, ”tag”), )
Detailed Description
This makes ( img && vacation ) a super key.
96
TravelMatch
Detailed Design Document
Member Data Documentation
tuple unique together = ((”vac”, ”tag”), ) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/models.py
ai.recommender system
B.12
ai.recommender system is a namespace that contains classes, variables and functions that relate to
the recommender system. This namespace contains functions for recommending locations given an
input set of likes and dislikes from the user. The recommendations are calculated using a Vector Space
Model, where each tag is a dimension in an n-dimensional graph and the similarity is calculated using
the cosine similarity function.
Functions
ˆ def calc recommendations (user input set, n, vacation)
The function that calclulates the n reccomended locations from some travelDNA The user input
consists of a array of likings and disliking with the according tagvalues.
ˆ def calculate travel dna (user input set)
Calculates the travelDNA given a user input set.
ˆ def get user dict (user travel dna)
Returns a dictionary which can be used to get the best match.
ˆ def normalize my tags (tag val list)
Returns a normalized user tag score for the tags.
ˆ def get best match (user travel dna, n, forbidden locations)
Gets the city that is the closest to the user travel dna using the cosine similiarity as measure.
ˆ def get city matrix (forbidden locations)
Normalizes all image values inside the database.
ˆ def normalize function (image value)
Normalization function of the city matrix.
ˆ def cosine similarity (user dict, city dict)
Computes the cosine similarity of the first dicitonary to the second dictionary.
Function Documentation
def ai.recommender system. cosine similarity ( user dict, city dict ) [private]
Computes the cosine similarity of the first dicitonary to the second dictionary.
Uses an optimized method for increased speed. All values of the tag values should be 0 <= v <=
100
Parameters
user dict
<user dict>
city dict
<city dict>
A dictionary containing user tag ids with their values.
dictionary
A dictionary containing city tag ids with their values.
dictionary
Returns
Float with the cosine similarity.
def ai.recommender system. get best match ( user travel dna, n, forbidden locations )
[private]
Gets the city that is the closest to the user travel dna using the cosine similiarity as measure.
97
TravelMatch
Detailed Design Document
Parameters
user travel dna
<user travel←dna>
n
<n>
forbidden ←locations
<forbidden ←locations>
The TravelDNA of the user
Dictionary
The number of locations needed
int
the input location lists
[Location]
Returns
A list of city ids which are the best match.
def ai.recommender system. get city matrix ( forbidden locations ) [private]
Normalizes all image values inside the database.
Returns
city matrix dict with normalized values, {city id: {image id: image val}} example: {1: {1: 0.5,
2: 0.7}, 2: {1: 0.9, 2: 0.65}}
def ai.recommender system. get user dict ( user travel dna ) [private]
Returns a dictionary which can be used to get the best match.
Parameters
user travel dna
<user travel←dna>
The TravelDNA of the user
Dictionary
Returns
A dictionary where {tag id: tag val norm}
def ai.recommender system. normalize function (
Normalization function of the city matrix.
Currently 0..100 –> 0..1
Parameters
image value
<image ←value>
image value ) [private]
The image value to be normalized
int
Returns
Returns a normalized float image value from 0..1
def ai.recommender system. normalize my tags (
Returns a normalized user tag score for the tags.
98
tag val list ) [private]
TravelMatch
Detailed Design Document
Parameters
tag val list
<tag val list>
A list of two items: [current user score, total potential score]
int[]
Returns
Normalized current score / total potential score if v[1] > 0 else 0
def ai.recommender system.calc recommendations ( user input set, n, vacation ) The
function that calclulates the n reccomended locations from some travelDNA The user input consists
of a array of likings and disliking with the according tagvalues.
So it consists of [ {'like': True, 0: val0, 1: val1, 2: val2, .., n: valn}, ... ] where the 'like' key is a
boolean that represents a liking. The 0 to n keys are the id's of all n active tags in the database with
their corresponding values for the image that was liked/disliked. If no value was given for a tag the
value is set to 0.
Precondition
0 <= val <= 100 for all values
all tag id's are in the dictonary
n == 1 || n == 2
Postcondition
len(returned) == n || len(returned) == 0
Parameters
user input set
<user input ←set>
n
<n>
vacation
<vacation>
[ {'like': True, 0: val0, 1: val1, 2: val2, .., n: valn}, ..., ]
dictionary
The amount of locations that have to be recommended.
n
the input vacation
VacationDetails
Returns
List of loc id of length n or empty array when the AI fails
def ai.recommender system.calculate travel dna ( user input set )
given a user input set.
Calculates the travelDNA
Precondition
0 <= tag value <= 100
Parameters
user input set
<user input ←set>
[{'like': True, '0': 30, '1': 10}, ..., {'like': False, '4': 0, '33': 100}]
dictionary
Returns
The TravelDNA of a user where TravelDNA = ['0': [user val, total val], ..., '33': [user val,
total val]]
99
TravelMatch
B.13
Detailed Design Document
ai.serializers
ai.serializer is a namespace that contains classes, variables and functions that relate to the AI
serializers. This namespace contains Django serializers, which verify and modify the input and output
of data in the model.
Classes
ˆ class LocationSerializer
This makes a django serializer object for the Location class.
ˆ class Meta
This creates the serializer with specific model and fields.
ˆ class TripOfferSerializer
This is for trip offer serializer.
Functions
ˆ def validate city name (self, value)
this method returns validated city name
ˆ def validate country name (self, value)
this method returns validated city name
ˆ def validate region name (self, value)
this method returns validated city name
Function Documentation
def ai.serializers.validate city name (
Parameters
value
<value>
self,
value ) this method returns validated city name
the input city name
string
Precondition
len(value) == 0
Exceptions
ValidationError
if precondition is violated
Returns
value: city name.lower(), it is case insensitive
def ai.serializers.validate country name ( self, value )
Parameters
value
<value>
the input country name
string
Precondition
len(value) == 0
100
this method returns validated city name
TravelMatch
Detailed Design Document
Exceptions
ValidationError
if precondition is violated
Returns
value: country name.lower(), it is case insensitive
def ai.serializers.validate region name ( self, value )
Parameters
value
<value>
this method returns validated city name
the input region name (string)
string
Precondition
len(value) == 0
Exceptions
ValidationError
if precondition is violated
Returns
value: region name.lower(), it is case insensitive
B.13.1
LocationSerializer
This makes a django serializer object for the Location class.
Inheritance diagram for LocationSerializer:
ModelSerializer
LocationSerializer
Detailed Description
This makes a django serializer object for the Location class.
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/serializers.py
B.13.2
Meta
This creates the serializer with specific model and fields.
Static Public Attributes
ˆ model = Location
ˆ list fields = ['loc id', 'city name', 'country name', 'region name']
ˆ tuple fields
Detailed Description
This creates the serializer with specific model and fields.
This create a model and a fields for the serializer.
101
TravelMatch
Detailed Design Document
Member Data Documentation
list fields = ['loc id', 'city name', 'country name', 'region name'] [static]
tuple fields [static]
Initial value:
1 = (’offer id’, ’name’, ’description’, ’hotel stars’, ’price’, ’link’,
2
’image’, ’min people’, ’dept date’, ’duration days’, ’user rating’, )
model = Location [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/serializers.py
B.13.3
TripOfferSerializer
This is for trip offer serializer.
Inheritance diagram for TripOfferSerializer:
ModelSerializer
TripOfferSerializer
Detailed Description
This is for trip offer serializer.
The documentation for this class was generated from the following file:
ˆ travelmatch/ai/serializers.py
B.14
ai.views
ai.views is a namespace that contains classes, variables and functions that relate to the artificial
intelligence views. This namespace would contain Django view controllers for managing the artificial
intelligence data; however, as no Django view controllers are required, this namespace is left empty.
B.15
appusers
appusers is a namespace that contains classes, variables and functions that relate to the user management components. This namespace mainly acts as a container for several other namespaces, namely
those relating to authentication, Mailgun integration, the models, serializers and views.
Namespaces
ˆ
ˆ
ˆ
ˆ
ˆ
authentication
mailgun
models
serializers
views
102
TravelMatch
B.16
Detailed Design Document
appusers.authentication
appusers.authentication is a namespace that contains classes, variables and functions that relate to
user authentication. This namespace contains a class that implements the abstract JSONWebTokenAuthentication
class from the JSON Web Token library, to provide a custom authentication function that authenticates
TravelMatch-specific credentials.
Classes
ˆ class MyJSONWebTokenAuthenticator
inherits authentication mechanism from JSONWebTokenAuthentication
Variables
ˆ
ˆ
ˆ
ˆ
jwt
jwt
jwt
jwt
payload handler = api settings.JWT PAYLOAD HANDLER
encode handler = api settings.JWT ENCODE HANDLER
decode handler = api settings.JWT DECODE HANDLER
get user id from payload = api settings.JWT PAYLOAD GET USER ID HANDLER
Variable Documentation
jwt decode handler = api settings.JWT DECODE HANDLER
jwt encode handler = api settings.JWT ENCODE HANDLER
jwt get user id from payload = api settings.JWT PAYLOAD GET USER ID HANDLER
jwt payload handler = api settings.JWT PAYLOAD HANDLER
B.16.1
MyJSONWebTokenAuthenticator
inherits authentication mechanism from JSONWebTokenAuthentication
Inheritance diagram for MyJSONWebTokenAuthenticator:
JSONWebTokenAuthentication
MyJSONWebTokenAuthenticator
Public Member Functions
ˆ def authenticate credentials (self, payload)
Returns an active user that matches the payload's user id and email.
Detailed Description
inherits authentication mechanism from JSONWebTokenAuthentication
Member Function Documentation
def authenticate credentials (
payload's user id and email.
self,
payload
103
)
Returns an active user that matches the
TravelMatch
Detailed Design Document
Parameters
payload
<payload>
The input user
object
Precondition
payload is a valid user with valid content
Returns
user: The correlated user object
Exceptions
AuthenticationFailed
if the precondition failed
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/authentication.py
B.17
appusers.mailgun
appusers.mailgun is a namespace that contains classes, variables and functions that relate to Mailgun
integration. This namespace contains function to send e-mails to TravelMatch users on behalf of
TravelMatch, via Mailgun. A built-in function is also provided to send confirmation e-mails for newly
registered users.
Functions
ˆ def send to mailgun (sender, to, subject, htmltext, plaintext)
The actual sending of the message with desired variables.
ˆ def create htmltext (to, userid, key)
Creating the email in html.
ˆ def create plaintext (to, userid, key)
Creating the email in plaintext.
ˆ def send confirmation message (to, userid, key)
This function can be called from anywhere else in the server to have an email created on and sent
with:
Variables
ˆ
ˆ
ˆ
ˆ
ˆ
string sender = ”nore[email protected]”
string subject = ”Confirm your new TravelMatch account”
string mailgun api base url = ”https://api.mailgun.net/v3/gotravelmatch.com/messages”
string mailgun api key = ”key-07bd4dbc95e6f5d62192e1d4d6a7ace5”
string AUTH LINK PATTERN = BASE URL+API URL+”/user/auth?userid={!s}&key={!s}”
Function Documentation
def appusers.mailgun.create htmltext (
to,
userid,
104
key )
Creating the email in html.
TravelMatch
Detailed Design Document
Parameters
to
<to>
userid
<userid>
key
<key>
the receivers' email address
[email]
the userid generated on the server for that new user
int
key generated to verify that the user indeed received the email on the specified
address
string
Returns
plaintext: the html text email with correct address, receivers and content
def appusers.mailgun.create plaintext (
Parameters
to
<to>
userid
<userid>
key
<key>
to,
userid,
key )
Creating the email in plaintext.
the receivers' email address
[email]
the userid generated on the server for that new user
int
key generated to verify that the user indeed received the email on the specified
address
string
Returns
plaintext: the plain text email with correct address, receivers and content
def appusers.mailgun.send confirmation message ( to, userid, key ) This function can be
called from anywhere else in the server to have an email created on and sent with:
Parameters
to
<to>
userid
<userid>
key
<key>
the receivers' email address
[email]
the userid generated on the server for that new user
int
key generated to verify that the user indeed received the email on the specified
address
string : the email address specified by the user to which the email is sent
def appusers.mailgun.send to mailgun ( sender, to,
The actual sending of the message with desired variables.
Parameters
sender
<sender>
to
<to>
email of the sender
string
email of the receiver
string
105
subject,
htmltext,
plaintext )
TravelMatch
htmltext
<htmltext>
plaintext
<plaintext>
subject
<subject>
Detailed Design Document
the htmltext to be sent
string
the plain text to be sent
string
subject of the email
string : email sent with input parameters
Variable Documentation
string AUTH LINK PATTERN = BASE URL+API URL+”/user/auth?userid={!s}&key={!s}”
string mailgun api base url = ”https://api.mailgun.net/v3/gotravelmatch.com/messages”
string mailgun api key = ”key-07bd4dbc95e6f5d62192e1d4d6a7ace5”
string sender = ”[email protected]”
string subject = ”Confirm your new TravelMatch account”
B.18
appusers.models
appusers.models is a namespace that contains classes, variables and functions that relate to the
artificial intelligence models. This namespace contains all Django models related to TravelMatch
users, including various types of user credentials, vacation details, pending activations, and saved trip
offers.
Classes
ˆ class AppUser
This is the class represents the application user of the application.
ˆ class FBAppUser
This represents the facebook users of the application users.
ˆ class GuestAppUser
This represents the guest user of the application.
ˆ class MailAppUser
This represents the mail user of the application user.
ˆ class PendingActivation
This represents the mail users yet to be activated.
ˆ class SavedLocation
This is the model for the trip saved locations.
ˆ class TripList
This model represents the list of trips the users have.
ˆ class TripListEntry
This is the model for the trip list entries.
ˆ class VacationDetail
This represents the detail of a certain vacation.
106
TravelMatch
Detailed Design Document
Functions
ˆ def encode
This function encode wit pbkdf2 method the password.
ˆ def verify (entered, encoded)
This function compares entered password with encoded password.
ˆ def default start date ()
This function sets the default start date return now()+timedelta(days=5): the 5 days after current
day.
ˆ def default end date ()
This function sets the default end date return now() + timedelta(days=5+7): the 5+7 days after
current day.
Function Documentation
def appusers.models.default end date ( ) This function sets the default end date return now()
+ timedelta(days=5+7): the 5+7 days after current day.
) This function sets the default start date return
def appusers.models.default start date (
now()+timedelta(days=5): the 5 days after current day.
def appusers.models.encode ( password,
encode wit pbkdf2 method the password.
Parameters
password
<password>
salt
<salt>
iterations
<iterations>
salt = None,
iterations = 10000 ) This function
the input password
string
the salt of the pbkdf2
string
iterations of pbkdf2
int
Precondition
None encode the password
Returns
hashed passowrd
def appusers.models.verify (
with encoded password.
Parameters
entered
<entered>
encoded
<entered>
entered,
encoded )
entered password
string
encoded password
string
Returns
True if encode(entered)==encoded
107
This function compares entered password
TravelMatch
B.18.1
Detailed Design Document
AppUser
This is the class represents the application user of the application.
Inheritance diagram for AppUser:
Model
AppUser
FBAppUser
GuestAppUser
MailAppUser
Classes
ˆ class Meta
This makes the humam-readable name of the table, and the means to sort it.
Public Member Functions
ˆ def is authenticated (self)
this set the authenticated to true
ˆ def
unicode
(self)
This returns the AppUser object in certain format in a string.
ˆ def display (self)
This display the user and it's user id.
ˆ def create
creating a new tuple (not update, just create)
ˆ def latest vac (self)
This returns the latest vacation of the app user.
Static Public Attributes
ˆ
ˆ
ˆ
ˆ
ˆ
tuple
tuple
tuple
tuple
tuple
user id = models.AutoField(primary key=True)
name = models.CharField(max length=500, null=False, default=””)
gender = models.CharField(max length=20, null=False, default=”none”)
birthday = models.DateField(null=False, default=date(1, 1, 1))
activation = models.BooleanField(default=True)
Detailed Description
This is the class represents the application user of the application.
Member Function Documentation
def
unicode
(
self )
This returns the AppUser object in certain format in a string.
Returns
string: u's s' % (self.user id, self.name)
108
TravelMatch
Detailed Design Document
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tuple (not update, just create)
using = None,
update←-
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def display (
self )
This display the user and it's user id.
Returns
string: ”AppUser ”+str(self.user id)
def is authenticated (
self ) this set the authenticated to true
Returns
True
def latest vac (
self ) This returns the latest vacation of the app user.
Precondition
vacs.last() exist
Returns
vacs.last(): the latest vacation from the query
Exceptions
error
if the precondition is violated
Member Data Documentation
tuple activation = models.BooleanField(default=True) [static]
tuple birthday = models.DateField(null=False, default=date(1, 1, 1)) [static]
tuple gender = models.CharField(max length=20, null=False, default=”none”) [static]
tuple name = models.CharField(max length=500, null=False, default=””) [static]
109
TravelMatch
Detailed Design Document
tuple user id = models.AutoField(primary key=True) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.2
AppUser.Meta
This makes the humam-readable name of the table, and the means to sort it.
Static Public Attributes
ˆ string verbose name = ”App User”
ˆ tuple ordering = ('user id',)
< the human readable name is ”App User”
Detailed Description
This makes the humam-readable name of the table, and the means to sort it.
Member Data Documentation
tuple ordering = ('user id',) [static]
< the human readable name is ”App User”
string verbose name = ”App User” [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.3
FBAppUser
This represents the facebook users of the application users.
Inheritance diagram for FBAppUser:
Model
AppUser
FBAppUser
Public Member Functions
ˆ def display (self)
Returns the facebook user with certain format in a string ”@return FBUser ”+str(self.user id)+”
”+str(self.fbid)
Static Public Attributes
ˆ tuple fbid = models.CharField(max length=256, blank=False)
Detailed Description
This represents the facebook users of the application users.
110
TravelMatch
Detailed Design Document
Member Function Documentation
def display ( self ) Returns the facebook user with certain format in a string ”@return FBUser
”+str(self.user id)+” ”+str(self.fbid)
Member Data Documentation
tuple fbid = models.CharField(max length=256, blank=False) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.4
GuestAppUser
This represents the guest user of the application.
Inheritance diagram for GuestAppUser:
Model
AppUser
GuestAppUser
Public Member Functions
ˆ def display (self)
Returns the guest user with certain format in a string ”@return ”GuestAppUser ”+str(self.user id)+”
”+str(self.timestamp)
Static Public Attributes
ˆ tuple device id = models.CharField(max length=250, blank=False, primary key=True)
ˆ tuple timestamp = models.DateTimeField(auto now=True)
Detailed Description
This represents the guest user of the application.
Member Function Documentation
def display ( self ) Returns the guest user with certain format in a string ”@return ”GuestAppUser
”+str(self.user id)+” ”+str(self.timestamp)
Member Data Documentation
tuple device id = models.CharField(max length=250, blank=False, primary key=True) [static]
tuple timestamp = models.DateTimeField(auto now=True) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
111
TravelMatch
B.18.5
Detailed Design Document
MailAppUser
This represents the mail user of the application user.
Inheritance diagram for MailAppUser:
Model
AppUser
MailAppUser
Public Member Functions
ˆ def send activation (self)
< email of the user (string)
ˆ def display (self)
Return the Mail user in certain format.
Public Attributes
ˆ activation
Static Public Attributes
ˆ tuple password = models.CharField(max length=256, blank=False)
ˆ tuple email = models.CharField(max length=256, blank=False)
< hashed password of the user (string)
Detailed Description
This represents the mail user of the application user.
Member Function Documentation
def display (
self )
Return the Mail user in certain format.
Returns
”MailUser ”+str(self.user id)+” ”+str(self.email)
def send activation ( self ) < email of the user (string)
This function send the activation key to the mail user and removes old pending activations
Precondition
None
Postcondition
sent the email
Returns
Void
112
TravelMatch
Detailed Design Document
Member Data Documentation
activation
tuple email = models.CharField(max length=256, blank=False) [static]
< hashed password of the user (string)
tuple password = models.CharField(max length=256, blank=False) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.6
PendingActivation
This represents the mail users yet to be activated.
Inheritance diagram for PendingActivation:
Model
PendingActivation
Classes
ˆ class Meta
This set the default ordering of PendingActivations to DESC timestemp.
Public Member Functions
ˆ def
unicode
(self)
Returns the PendingActivation with certain format in a string.
Static Public Member Functions
ˆ def id generator
This method generates the id.
Static Public Attributes
ˆ tuple user = models.ForeignKey(MailAppUser)
ˆ tuple timestamp = models.DateTimeField(auto now add=True)
ˆ tuple key = models.CharField(max length=255, null=False)
Detailed Description
This represents the mail users yet to be activated.
Member Function Documentation
def
unicode
(
self )
Returns the PendingActivation with certain format in a string.
Returns
: u's: user s -> s' % (self.timestamp, self.user, self.key)
113
TravelMatch
Detailed Design Document
def id generator (
size = 20,
[static]
This method generates the id.
Parameters
size
<size>
chars
<chars>
chars = string.ascii uppercase + string.digits
the size of the id. default value is 20 (int)
int
the id will be generated using the characters from this, default all cases letters (list)
list
Returns
string: ''.join(random.choice(chars) for
in range(size))
Member Data Documentation
tuple key = models.CharField(max length=255, null=False) [static]
tuple timestamp = models.DateTimeField(auto now add=True) [static]
tuple user = models.ForeignKey(MailAppUser) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.7
PendingActivation.Meta
This set the default ordering of PendingActivations to DESC timestemp.
Static Public Attributes
ˆ tuple ordering = ('-timestamp',)
Detailed Description
This set the default ordering of PendingActivations to DESC timestemp.
Member Data Documentation
tuple ordering = ('-timestamp',) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.8
)
SavedLocation
This is the model for the trip saved locations.
Inheritance diagram for SavedLocation:
Model
SavedLocation
114
TravelMatch
Detailed Design Document
Classes
ˆ class Meta
This class enforce loc list&&user as a super key.
Static Public Attributes
ˆ tuple loc = models.ForeignKey('ai.Location')
ˆ tuple user = models.ForeignKey(AppUser)
ˆ tuple loc list = models.ForeignKey(TripList)
Detailed Description
This is the model for the trip saved locations.
Member Data Documentation
tuple loc = models.ForeignKey('ai.Location') [static]
tuple loc list = models.ForeignKey(TripList) [static]
tuple user = models.ForeignKey(AppUser) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.9
SavedLocation.Meta
This class enforce loc list&&user as a super key.
Static Public Attributes
ˆ tuple unique together = ((”loc list”, ”user”),)
Detailed Description
This class enforce loc list&&user as a super key.
Member Data Documentation
tuple unique together = ((”loc list”, ”user”),) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.10
TripList
This model represents the list of trips the users have.
Inheritance diagram for TripList:
Model
TripList
115
TravelMatch
Detailed Design Document
Static Public Member Functions
ˆ def create trip list (offer ids)
Static Public Attributes
ˆ tuple trip list id = models.AutoField(primary key=True)
Detailed Description
This model represents the list of trips the users have.
Member Function Documentation
def create trip list (
offer ids ) [static]
Exceptions
ObjectDoesNotExist
is one of the loc ids doesn't exists anymore
Returns
a new TripList instance from the db
Member Data Documentation
tuple trip list id = models.AutoField(primary key=True) [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.11
TripListEntry
This is the model for the trip list entries.
Inheritance diagram for TripListEntry:
Model
TripListEntry
Public Member Functions
ˆ def generate api response (self)
< this is no foreign key to keep it even if the hotels disappear
Static Public Attributes
ˆ tuple trip list = models.ForeignKey(TripList, null=False)
ˆ tuple cached name = models.CharField(null=False, max length=64)
< list of trips
ˆ tuple trip offer id = models.IntegerField(null=True)
< see TripOffer.name
116
TravelMatch
Detailed Design Document
Detailed Description
This is the model for the trip list entries.
Member Function Documentation
def generate api response ( self ) < this is no foreign key to keep it even if the hotels disappear
This function returns a trip list as an api response
Returns
ser.data: the serialized TripOffer object
Member Data Documentation
tuple cached name = models.CharField(null=False, max length=64) [static]
< list of trips
tuple trip list = models.ForeignKey(TripList, null=False) [static]
tuple trip offer id = models.IntegerField(null=True) [static]
< see TripOffer.name
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.12
VacationDetail
This represents the detail of a certain vacation.
Inheritance diagram for VacationDetail:
Model
VacationDetail
Classes
ˆ class Meta
< timestamp of the last added TravelDNA (datetime)
Public Member Functions
ˆ def
unicode
(self)
this method returns the VacationDetail object in a string whenever we need to return a VacationDetail
object
ˆ def create
creating a new tag tuple (not update, just create)
ˆ def display user (self)
display the user
ˆ def display (self)
display the user
ˆ def persons total (self)
The total persons.
117
TravelMatch
Detailed Design Document
Static Public Attributes
ˆ tuple internal id = models.AutoField(primary key=True)
ˆ tuple user = models.ForeignKey(AppUser, null=False)
< This offers the internal id of the model (int) not in the db desigh
ˆ tuple vac id = models.PositiveSmallIntegerField(null=False, default=0)
< The user involved in the vacation (user)
ˆ tuple vac name = models.CharField(max length=256, null=False, blank=True, default=””)
< id of the vacation(int) the default vacation has id 0
ˆ tuple start date = models.DateField(null=False, blank=False, default=default start date())
< name of the vation, (string) ”” means the default vacation
ˆ tuple start date extend = models.SmallIntegerField(null=False, default=0)
< date vacation starts (date)
ˆ tuple end date = models.DateField(null=False, blank=False, default=default end date())
< the extend margin of the start date (int)
ˆ tuple end date extend = models.SmallIntegerField(null=False, default=0)
< date vacation ends (date)
ˆ tuple persons adults = models.PositiveSmallIntegerField(null=False, blank=False, default=1)
< extend margin of the end date (int)
ˆ tuple persons children = models.PositiveSmallIntegerField(null=False, default=0)
< number of adult persons involved (int)
ˆ tuple budget = models.PositiveIntegerField(null=False, default=0)
< number of children involved (int)
ˆ tuple last modified = models.DateTimeField(null=False, blank=False, auto now=True)
< buget of the vacation, in cents (int)
ˆ tuple unique together = ((”user”, ”vac id”),)
Detailed Description
This represents the detail of a certain vacation.
Member Function Documentation
def unicode ( self ) this method returns the VacationDetail object in a string whenever we
need to return a VacationDetail object
Returns
u's: s'%(self.user, self.vac name) out put string with certain format
def create ( self, force insert = False, force update = False,
fields = None ) creating a new tag tuple (not update, just create)
Precondition
the tuple does not exist int e database
Postcondition
tuple updated
118
using = None,
update←-
TravelMatch
Detailed Design Document
Exceptions
IntegrityError
if the was precondition violated
Returns
Void new Tag object
def display (
self )
display the user
Precondition
user.vac name == vac name
Returns
name of the vacation if it exist, else return ”Niet gedefineerd”
def display user (
self ) display the user
Returns
name (name of the user)
def persons total (
self ) The total persons.
Returns
persons adults + persons children
Member Data Documentation
tuple budget = models.PositiveIntegerField(null=False, default=0) [static]
< number of children involved (int)
tuple end date = models.DateField(null=False, blank=False, default=default end date())
[static]
< the extend margin of the start date (int)
tuple end date extend = models.SmallIntegerField(null=False, default=0) [static]
< date vacation ends (date)
tuple internal id = models.AutoField(primary key=True) [static]
tuple last modified = models.DateTimeField(null=False, blank=False, auto now=True) [static]
< buget of the vacation, in cents (int)
tuple persons adults = models.PositiveSmallIntegerField(null=False, blank=False, default=1)
[static]
< extend margin of the end date (int)
tuple persons children = models.PositiveSmallIntegerField(null=False, default=0) [static]
< number of adult persons involved (int)
119
TravelMatch
Detailed Design Document
tuple start date = models.DateField(null=False, blank=False, default=default start date())
[static]
< name of the vation, (string) ”” means the default vacation
tuple start date extend = models.SmallIntegerField(null=False, default=0) [static]
< date vacation starts (date)
tuple unique together = ((”user”, ”vac id”),) [static]
tuple user = models.ForeignKey(AppUser, null=False) [static]
< This offers the internal id of the model (int) not in the db desigh
tuple vac id = models.PositiveSmallIntegerField(null=False, default=0) [static]
< The user involved in the vacation (user)
tuple vac name = models.CharField(max length=256, null=False, blank=True, default=””)
[static]
< id of the vacation(int) the default vacation has id 0
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.18.13
VacationDetail.Meta
< timestamp of the last added TravelDNA (datetime)
Detailed Description
< timestamp of the last added TravelDNA (datetime)
This makes (user && vac id) a super key
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/models.py
B.19
appusers.serializers
appusers.serializer is a namespace that contains classes, variables and functions that relate to
the AI serializers. This namespace contains Django serializers, which verify and modify the input and
output of data in the model.
Classes
ˆ class FBUserSerializer
This makes a django serializer object for the FBAppUser class.
ˆ class GuestAccountSerializer
This makes a django serializer object for the GuestAppUser class.
ˆ class MailUserSerializer
This makes a django serializer object for the MailUser class.
ˆ class Meta
This creates the serializer with specific model and fields.
ˆ class UserSerializer
120
TravelMatch
Detailed Design Document
This makes a django serializer object for the AppUser class.
ˆ class VacationDetailsSerializer
This makes a django serializer object for the VacationDetail class.
Functions
ˆ def validate email (self, value)
this method returns validated email
ˆ def validate password (self, value)
this method returns validated password
ˆ def validate fbid (self, value)
this method returns validated fbid
ˆ def validate device id (self, value)
this method returns validated device id
ˆ def validate user (self, value)
this method returns validated user
ˆ def validate vac id (self, value)
this method returns validated vac id
ˆ def validate start date (self, value)
this method returns validated
ˆ def validate end date (self, value)
this method returns validated end date
ˆ def validate persons adults (self, value)
this method returns validated persons
ˆ def validate vac name (self, value)
this method returns validated vac name
ˆ def validate budget (self, value)
this method returns validated budget
Variables
ˆ list VAC FIELDS
Function Documentation
def appusers.serializers.validate budget (
Parameters
value
<value>
self,
the input budget
int
Precondition
value < 0
Exceptions
121
value ) this method returns validated budget
TravelMatch
Detailed Design Document
ValidationError
if precondition is violated
Returns
value: validated budget
def appusers.serializers.validate device id (
device id
Parameters
value
<value>
self,
value
)
this method returns validated
the input device id
string
Returns
fbid: facebook id and it is validated
def appusers.serializers.validate email (
Parameters
value
<value>
self,
value ) this method returns validated email
the input city name
string
Precondition
len(value) == 0
Exceptions
ValidationError
if precondition is violated
Returns
value: mail.lower(), it is case insensitive
def appusers.serializers.validate end date (
end date
Parameters
value
<value>
self,
value
)
this method returns validated
the input end date (date)
DateField
Returns
end date and it is validated
def appusers.serializers.validate fbid (
Parameters
value
<value>
self,
value ) this method returns validated fbid
the input fbid
string
Returns
fbid: facebook id and it is validated
def appusers.serializers.validate password (
password
self,
122
value
) this method returns validated
TravelMatch
Detailed Design Document
Parameters
value
<value>
the input password
string
Precondition
len(value) == 0
Exceptions
ValidationError
if precondition is violated
Returns
value: password and it is validated
def appusers.serializers.validate persons adults (
persons
Parameters
value
<value>
self,
value )
this method returns validated
the personsNI
int
Returns
value: persons and it is validated
def appusers.serializers.validate start date (
Parameters
value
<value>
self,
value ) this method returns validated
the input start date
DateField
Returns
value: start date and it is validated
def appusers.serializers.validate user (
Parameters
value
<value>
self,
value ) this method returns validated user
the input user (User object)
AppUser
Returns
user and it is validated
def appusers.serializers.validate vac id (
Parameters
value
<value>
self,
value ) this method returns validated vac id
the input vac id
VacationDetail
Returns
value: vac id and it is validated
def appusers.serializers.validate vac name (
vac name
self,
123
value
)
this method returns validated
TravelMatch
Detailed Design Document
Parameters
value
<value>
the input vac name
string
Precondition
value != null
Exceptions
ValidateError
if precondition is violated
Returns
value: validated vacation name
Variable Documentation
list VAC FIELDS
Initial value:
1 = [’user’, ’vac id’, ’vac name’, ’start date’, ’start date extend’, ’end date’, ’end date extend’,
2
’persons adults’, ’persons children’, ’budget’]
B.19.1
FBUserSerializer
This makes a django serializer object for the FBAppUser class.
Inheritance diagram for FBUserSerializer:
ModelSerializer
FBUserSerializer
Detailed Description
This makes a django serializer object for the FBAppUser class.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/serializers.py
B.19.2
GuestAccountSerializer
This makes a django serializer object for the GuestAppUser class.
Inheritance diagram for GuestAccountSerializer:
ModelSerializer
GuestAccountSerializer
Detailed Description
This makes a django serializer object for the GuestAppUser class.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/serializers.py
124
TravelMatch
B.19.3
Detailed Design Document
MailUserSerializer
This makes a django serializer object for the MailUser class.
Inheritance diagram for MailUserSerializer:
ModelSerializer
MailUserSerializer
Detailed Description
This makes a django serializer object for the MailUser class.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/serializers.py
B.19.4
Meta
This creates the serializer with specific model and fields.
Static Public Attributes
ˆ
ˆ
ˆ
ˆ
model = AppUser
tuple fields = ('name', 'gender', 'birthday')
list fields = ['email', 'password']
fields = VAC FIELDS
Detailed Description
This creates the serializer with specific model and fields.
Member Data Documentation
tuple fields = ('name', 'gender', 'birthday') [static]
list fields = ['email', 'password'] [static]
fields = VAC FIELDS [static]
model = AppUser [static]
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/serializers.py
125
TravelMatch
B.19.5
Detailed Design Document
UserSerializer
This makes a django serializer object for the AppUser class.
Inheritance diagram for UserSerializer:
ModelSerializer
UserSerializer
Detailed Description
This makes a django serializer object for the AppUser class.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/serializers.py
B.19.6
VacationDetailsSerializer
This makes a django serializer object for the VacationDetail class.
Inheritance diagram for VacationDetailsSerializer:
ModelSerializer
VacationDetailsSerializer
Detailed Description
This makes a django serializer object for the VacationDetail class.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/serializers.py
B.20
appusers.views
appusers.views is a namespace that contains classes, variables and functions that relate to the
artificial intelligence views. This namespace contain Django controllers for the TravelMatch API, as
well as mappings from REST endpoints to Django functions.
Classes
ˆ class APIError
default class that just returns an error
ˆ class APIRecommendation
This class queries existing VacationDetail to see its recommendation.
ˆ class APIUser
API for log in related issues, this class is used whenever a url(api pattern.format('/user') is called.
ˆ class APIUserAuth
API for MailUser authentication, when url(api pattern.format('/user/auth'), APIUserAuth.as view())
is called.
126
TravelMatch
Detailed Design Document
ˆ class APIUserHotel
This class gets the hotel user use for certain trip offer.
ˆ class APIUserLocation
This is for get and post SaveLocation from AppUser.
ˆ class APIUserLogin
API for log in, when url(api pattern.format('/user/login'), APIUserLogin.as view()), is called.
ˆ class APIUserMe
API for retrieve and modify ones profile.
ˆ class APIUserMyLocation
This is the api for the location of an user.
ˆ class APIUserMyLocationAll
API for getting all of user's locations.
ˆ class APIUserMyLocationAllValues
This is the API to get all the value from a user's locations.
ˆ class APIUserSwipe
The API for the swipe operations carried out by users.
ˆ class APIUserVacationDetails
API for user's vacation details.
ˆ class APIUserVacationDetailsAllValues
This is the API for query all the VacationDetail object from a certain user.
ˆ class APIUserVacationDetailsLatest
This is the API for query all the VacationDetail object from a certain user.
ˆ class JSONResponse
An HttpResponse that renders its content into JSON.
Functions
ˆ def
init
(self, data, kwargs)
Initializing the data.
ˆ def create token response data (user)
This method is for creating a Json Web Token for the user.
ˆ def decode string (encoded)
Decoding the data from b64.
ˆ def encode string (s)
Encoding the data into b64.
ˆ def create encoding err resp (field)
This is for creating a http response if the field is not properly encoded.
ˆ def post
< The permission of the /user: is allowed by everyone
ˆ def delete (self, request)
This method delet a user.
ˆ def get (self, request)
< The permission of the /user: is allowed by everyone
ˆ def post (self, request)
< The permission of the /user: is allowed by everyone
ˆ def update field (key, data, obj)
This is the method to update the fields in an object.
127
TravelMatch
Detailed Design Document
ˆ def put (self, request)
This method update the field requested to be updated.
ˆ def create vacation response data (vac)
This function create a response for VacationDetail object.
ˆ def is unique vac name (vac name, vac id, vacs)
This method checks if certain vacation exist in the given list of vacations and its uniqueness.
ˆ def update vacation (vac, data)
Function that update and maintains the VactionDetail object if it exist.
ˆ def record swipe (vacation, img, like)
This method record a swipe operation carried out by user.
ˆ def create new images response (n, user, vac)
This is the method that calls the AI to get a new set of images based on the entropy calculation.
Variables
ˆ tuple logger = logging.getLogger( name )
ˆ string DEFAULT VACATION NAME = ”Vakantie”
ˆ tuple permission classes = (AllowAny, )
Function Documentation
def appusers.views. init
(
self,
data,
kwargs )
Initializing the data.
An HttpResponse that renders its content into JSON.
Precondition
None
Postcondition
None
Returns
None
def appusers.views.create encoding err resp ( field )
field is not properly encoded.
Parameters
field
<field>
This is for creating a http response if the
the field
field, django field
Precondition
field is not encoded
Returns
http response with the field, message that it is not encoded, and 400 http statues code
def appusers.views.create new images response ( n, user, vac ) This is the method that
calls the AI to get a new set of images based on the entropy calculation.
128
TravelMatch
Detailed Design Document
Parameters
n
<n>
user
<user>
vac
<vac>
amount of SwipeImages needed
int
the AppUser that needs SwipeImages
AppUser
input vacation details
VacationDetails
Precondition
n lager than 0
Returns
a list of SwipeImages
def appusers.views.create token response data (
Web Token for the user.
Parameters
user
<user>
user )
This method is for creating a Json
the user you need to create token for
AppUser
Precondition
None
Postcondition
None
Returns
response data the JWT containing the user information
def appusers.views.create vacation response data (
VacationDetail object.
Parameters
vac
<vac>
vac )
This function create a response for
the input VacationDetail object
VacationDetail
Precondition
the input is a VacationDetail object
Returns
response data with the vac as http response, but without vac.user
def appusers.views.decode string (
encoded ) Decoding the data from b64.
129
TravelMatch
Detailed Design Document
Parameters
encoded
<encoded>
the string you wish to decode
string
Precondition
None
Postcondition
None
Returns
decoded string from encoded
def delete ( self, request ) This method delet a user.
This method deletes a location.
This is the method for deleting VacationDetail objects.
Parameters
request
<request>
html request
html request
Returns
Response: response with corresponding http status code : request.user.delete(): if user exist,
remove the user from the database
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
None
Returns
response and http status code
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
the vacation exist, the loc id exist
Returns
Response: string message with whether get operations is successful with http status code
def appusers.views.encode string (
s ) Encoding the data into b64.
130
TravelMatch
Detailed Design Document
Parameters
s
<s>
the sting you wish to encode
string
Precondition
None
Postcondition
None
Returns
encoded string from s
def get ( self, request ) < The permission of the /user: is allowed by everyone
This method returns all the hotels and its id for a TripOffer.
This method queries for Locations.
This method queries for Location.
This method queries for Savelocation.
This method queries for recommendation.
This method queries for n images for certain vacation.
This is the function that query all the VacationDetail object from a certain user.
This is the method for querying and returning VacationDetail object.
This methods fetch and returns the user data.
This is the function that sends the authentication token
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
it is from a MailUser and the information is correct None
Returns
response with authenticity token
Exceptions
def appusers.views.is unique vac name ( vac name, vac id, vacs ) This method checks if
certain vacation exist in the given list of vacations and its uniqueness.
Parameters
vac name
<vac name>
name of the vacation
string
131
TravelMatch
vac id
<vac id>
vacs
<vacs>
Detailed Design Document
id of the vacation
int
the list of vacation to be checked
[VacationDetails]
Returns
True if vacation in vac and it is unique, False otherwise
def appusers.views.post ( self, request, format = None ) < The permission of the /user:
is allowed by everyone
This methods post the data from the request check it and stores them in the database
Parameters
request
<request>
format
<format>
the incoming http request
HttpRequest
the format
format
Precondition
the user information sent via request is either a MailUser or a FB user
Returns
access token
Exceptions
error
if precondition is violated
def post ( self, request ) < The permission of the /user: is allowed by everyone
This method storing for location.
This method records a swipe and then provide a new image to swipe.
This method creates a new VacationDetail Object from.
This returns an access token for log in
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
the request is a valid request with correct criteria for a FBUser or a MailUser
Postcondition
None
Returns
response with access token
132
TravelMatch
Detailed Design Document
Exceptions
error
and corresponding http status code if the precondition is violated
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
None
Postcondition
the VacationDetail updated if it exist beforehand
Returns
http response with the updated data if it exist beforehand, message with http status code otherwise
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
request.data.image and the like exist, and there are more than 'n' images in the request.data to
swipe, image exist : new swipe recorded
Returns
Response: string message with whether input satisfy the preconditions, the response with http
status code
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
request.data['loc id'] exist along with the request.data['user'] : new SaveLocation saved
Returns
Response: serialized message with SaveLocation object if it exist, and the response with http
status code
def put ( self, request ) This method update the field requested to be updated.
This function puts the requested data JSONResponse and returns it.
133
TravelMatch
Detailed Design Document
Parameters
request
<request>
the incoming http request
HttpRequest
Precondition
None
Postcondition
None : the data that needs to be modified, if it exist
Returns
response with corresponding http status code
Parameters
request
<request>
http request
http request
Returns
JSONResponse with corresponding http status code
def appusers.views.record swipe (
operation carried out by user.
Parameters
vacation
<vacation>
img
<img>
like
<like>
img
<img>
vacation,
img,
like
) This method record a swipe
the vacation that being recorded
VacationDetail
the swipe image involved
SwipeImage
whether user liked the image or not
boolean
the input swipe image
SwipeImage
Precondition
there are no more than 1 TravelDNA with the same vacation && img the new swipe stored
Exceptions
IntegrityError
if precondition is violated
Returns
swipe: the input swipe with vaction, img, and like
def appusers.views.update field (
in an object.
key,
data,
134
obj )
This is the method to update the fields
TravelMatch
Detailed Design Document
Parameters
key
<key>
data
<data>
obj
<obj>
the keys with update of the object
abstract data type
the input data
data
the object
object
Precondition
None
Returns
modified the updated data
def appusers.views.update vacation (
VactionDetail object if it exist.
Parameters
vac
<vac>
data
<data>
vac,
data ) Function that update and maintains the
the VacationDetail object that needs to be updated
VacationDetail
the new data for the update
data
Precondition
the related VacationDetail exists
Postcondition
the VacationDetail object up to date
Returns
response with up to date vac, or an error message with http status code
Variable Documentation
string DEFAULT VACATION NAME = ”Vakantie”
tuple logger = logging.getLogger( name )
tuple permission classes = (AllowAny, )
B.20.1
APIError
default class that just returns an error
Inheritance diagram for APIError:
APIView
APIError
135
TravelMatch
Detailed Design Document
Detailed Description
default class that just returns an error
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.2
APIRecommendation
This class queries existing VacationDetail to see its recommendation.
Inheritance diagram for APIRecommendation:
APIView
APIRecommendation
Detailed Description
This class queries existing VacationDetail to see its recommendation.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.3
APIUser
API for log in related issues, this class is used whenever a url(api pattern.format('/user') is called.
Inheritance diagram for APIUser:
APIView
APIUser
Detailed Description
API for log in related issues, this class is used whenever a url(api pattern.format('/user') is called.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.4
APIUserAuth
API for MailUser authentication, when url(api pattern.format('/user/auth'), APIUserAuth.as view())
is called.
Inheritance diagram for APIUserAuth:
APIView
APIUserAuth
136
TravelMatch
Detailed Design Document
Detailed Description
API for MailUser authentication, when url(api pattern.format('/user/auth'), APIUserAuth.as view())
is called.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.5
APIUserHotel
This class gets the hotel user use for certain trip offer.
Inheritance diagram for APIUserHotel:
APIView
APIUserHotel
Detailed Description
This class gets the hotel user use for certain trip offer.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.6
APIUserLocation
This is for get and post SaveLocation from AppUser.
Inheritance diagram for APIUserLocation:
APIView
APIUserLocation
Detailed Description
This is for get and post SaveLocation from AppUser.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.7
APIUserLogin
API for log in, when url(api pattern.format('/user/login'), APIUserLogin.as view()), is called.
Inheritance diagram for APIUserLogin:
APIView
APIUserLogin
137
TravelMatch
Detailed Design Document
Detailed Description
API for log in, when url(api pattern.format('/user/login'), APIUserLogin.as view()), is called.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.8
APIUserMe
API for retrieve and modify ones profile.
Inheritance diagram for APIUserMe:
APIView
APIUserMe
Detailed Description
API for retrieve and modify ones profile.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.9
APIUserMyLocation
This is the api for the location of an user.
Inheritance diagram for APIUserMyLocation:
APIView
APIUserMyLocation
Detailed Description
This is the api for the location of an user.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.10
APIUserMyLocationAll
API for getting all of user's locations.
Inheritance diagram for APIUserMyLocationAll:
APIView
APIUserMyLocationAll
138
TravelMatch
Detailed Design Document
Detailed Description
API for getting all of user's locations.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.11
APIUserMyLocationAllValues
This is the API to get all the value from a user's locations.
Inheritance diagram for APIUserMyLocationAllValues:
APIView
APIUserMyLocationAllValues
Detailed Description
This is the API to get all the value from a user's locations.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.12
APIUserSwipe
The API for the swipe operations carried out by users.
Inheritance diagram for APIUserSwipe:
APIView
APIUserSwipe
Detailed Description
The API for the swipe operations carried out by users.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.13
APIUserVacationDetails
API for user's vacation details.
Inheritance diagram for APIUserVacationDetails:
APIView
APIUserVacationDetails
139
TravelMatch
Detailed Design Document
Detailed Description
API for user's vacation details.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.14
APIUserVacationDetailsAllValues
This is the API for query all the VacationDetail object from a certain user.
Inheritance diagram for APIUserVacationDetailsAllValues:
APIView
APIUserVacationDetailsAllValues
Detailed Description
This is the API for query all the VacationDetail object from a certain user.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.15
APIUserVacationDetailsLatest
This is the API for query all the VacationDetail object from a certain user.
Inheritance diagram for APIUserVacationDetailsLatest:
APIView
APIUserVacationDetailsLatest
Detailed Description
This is the API for query all the VacationDetail object from a certain user.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
B.20.16
JSONResponse
An HttpResponse that renders its content into JSON.
Inheritance diagram for JSONResponse:
HttpResponse
JSONResponse
140
TravelMatch
Detailed Design Document
Detailed Description
An HttpResponse that renders its content into JSON.
The documentation for this class was generated from the following file:
ˆ travelmatch/appusers/views.py
141
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement