Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVP #5

Merged
merged 2 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ class Journey(UserMixin, db.Model):
price = db.Column(db.String, nullable=False)
picture = db.Column(db.String, nullable=False)

def __init__(self, creator_id='', title='', description='', location='', duration='', category='', requirements='', people_range='', picture='', price='' ):
self.creator_id = creator_id
self.title = title
self.description = description
self.location = location
self.duration = duration
self.category = category
self.requirements = requirements
self.people_range = people_range
self.picture = picture
self.price = price

def __init__(self, creator_id='', title='', description='', location='', duration='', category='', requirements='', people_range='', picture='', price=''):
self.creator_id = creator_id
self.title = title
self.description = description
self.location = location
self.duration = duration
self.category = category
self.requirements = requirements
self.people_range = people_range
self.picture = picture
self.price = price


def __repr__(self):
Expand Down
9 changes: 7 additions & 2 deletions project/templates/apply.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{% extends "layout.html" %}
{% block content %}

<!DOCTYPE html>
<html>
<head>
<title>story teller</title>
<h1>Become A StoryTeller</h1>
</head>
<body>
Hi____,

Hi {{ current_user.name }},
<br><br><br>
<p>Becoming a storyteller means you will get to share your ambitious insipring story of your life. you will be free to take people on a journey in the places you grew in or places you would like.</p>

Expand Down Expand Up @@ -68,4 +72,5 @@ <h4>add image url</h4>

</form>
</body>
</html>
</html>
{% endblock %}
10 changes: 5 additions & 5 deletions project/templates/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@




<div>
{% for journey in journeys %}
{% for journey in all_journeys %}
<div>
<img src="{{ journey.picture }}" width=500 height=265 >
<h5>{{ journey.start_location }}</h5><br>
<h3>{{ journey.title }}</h3><br>
<img src="{{url_for('static', filename='profile.png')}}" width=500 height=265 >
<h5>{{ journey.title }}</h5><br>
<h3>{{ journey.location }}</h3><br>
<p>{{ journey.price }}</p><br>
<p>{{ journey.category }}</p><br>
<a href="{{url_for('display_journey', journey_id=journey.id)}}"> View Details </a>
</div>
{% endfor %}

Expand Down
2 changes: 1 addition & 1 deletion project/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends "layout.html" %}
{% block content %}
<h1>Hello world!</h1>
<h1> ROOTS </h1>
{% endblock %}
11 changes: 6 additions & 5 deletions project/templates/journey.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@


{% extends "layout.html" %}
{% block content %}
<div> <img class="img1" src="{{journey.picture}}"> </div>
<div> <img class="img1" src="{{ journey.picture }}"> </div>
<div> <h1> {{journey.title}} </h1>
<h1> start location : {{journey.start_location}} </h1>
<!-- **REMEMBER TO LINK IT TO THE PROFILE** -->
<h1> storyteller : {{creator.name}} </h1>
<h1> end location : {{journey.end_location}} </h1>
<h1> storyteller : {{ creator.name }} </h1>
<h1> location : {{journey.location}} </h1>
<h1> description : {{journey.description}} </h1>
<h1> duration : {{journey.duration}} </h1>
<h1> price : {{journey.price}} </h1>
<h1> category : {{journey.category}} </h1>
<h1> requirments : {{journey.requirments}} </h1>
<h1> requirements : {{journey.requirements}} </h1>
<h1> people range : {{journey.people_range}} </h1>


Expand Down
19 changes: 0 additions & 19 deletions project/templates/journey_table_test.html

This file was deleted.

2 changes: 2 additions & 0 deletions project/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<script src="{{ url_for('static', filename='js/script.js') }}"></script>
</head>
<body>

current user: {{ current_user.name }}
<!-- child template -->
{% block content %}
{% endblock %}
Expand Down
11 changes: 9 additions & 2 deletions project/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

users_bp = Blueprint('users', __name__)

current_user = 'Not Logged In'
# current_user = 'Not Logged In'

@users_bp.route('/register', methods=['GET', 'POST'])
def register():
Expand Down Expand Up @@ -61,11 +61,18 @@ def login():
if user is None or not user.check_password(password):
return Response("<p>Incorrect email or password</p>")
login_user(user, remember=True)


# next_page = request.args.get('next')
# if not next_page or url_parse(next_page).netloc != '':
# #return render_template('browse.html', current_user=user)
# next_page = url_for('browse')

# next_page = request.args.get('next')
# if not next_page or url_parse(next_page).netloc != '':
# next_page = url_for('private_route')

return redirect(url_for('block_journey'))
return redirect(url_for('browse'))
else:
return Response("<p>invalid form</p>")
return render_template('login.html', form=form)
Expand Down
37 changes: 22 additions & 15 deletions project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@ def private_route():
@app.route('/apply', methods=['GET', 'POST'])
@login_required
def apply():
# global current_user
# print(current_user)
user_id = session['user_id']
user = User.query.filter_by(id=user_id).first()
print(user.name)
if request.method=='POST':
user_info = User.query.filter_by(id=request.form.get('user_id')).first()
#print(user_info)
#print(request)
#print(user_info.one())
user_info.country = request.form.get('country')
user_info.profession = request.form.get('profession')
user_info.birthday = request.form.get('birthday')
user_info.city = request.form.get('city')
user_info.number = request.form.get('number')
db.session.add(user_info)
db.session.commit()
############################################### CONNECT THIS TO CURRENT USER ########################################################

################# JOURNEY TABLE ###################
new_journey = Journey()
#new_journey.creator_id = current_user.id
new_journey.creator_id = request.form.get('user_id')
new_journey.title = request.form.get('title')
new_journey.description = request.form.get('description')
new_journey.location = request.form.get('location')
Expand All @@ -46,30 +47,36 @@ def apply():
print(new_journey.description)
db.session.add(new_journey)
db.session.commit()
return render_template('journey_table_test.html', journey=new_journey)
return render_template('journey.html', journey=new_journey, current_user=user)
else:
return render_template('apply.html')
return render_template('apply.html', current_user=user)

@app.route('/journeys/<int:journey_id>')
def display_journey(journey_id):
journey = Journey.query.filter_by(id=journey_id).first()
creator = User.query.filter_by( id=journey.creator_id).first()
creator = User.query.filter_by(id=journey.creator_id).first()
return render_template('journey.html', journey=journey, creator= creator)

@app.route('/profile/<user_id>')
def profile(user_id):
user=User.query.filter_by (id=user_id).first()
is_user=False
# if user_email==current_user.email:
# is_user=True
return render_template('profile.html',user=user, is_user=is_user)
user_id = session['user_id']
current_user = User.query.filter_by(id=user_id).first()
if user.id==current_user.id:
is_user=True
return render_template('profile.html',user=user, is_user=is_user, current_user=current_user)

@app.route('/browse')
def block_journey():
all_journeys = db.session.query(Journey).all()
return render_template('browse.html', journey=all_journeys)
def browse():
user_id = session['user_id']
current_user = User.query.filter_by(id=user_id).first()
# WHAT ZAIN DID ===> all_journeys = db.session.query(Journey).all()
all_journeys = Journey.query.all()
return render_template('browse.html', all_journeys=all_journeys, current_user=current_user)
# we need to now how to filter



if __name__ == "__main__":
app.run()