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

merging new navbar into master #15

Open
wants to merge 164 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
3f83089
Finshed login and register flask
ben18-meet Jul 24, 2018
7da462c
fixed repo
aboud20-meet Jul 24, 2018
ea891b6
Merge branch 'master' of https://github.com/Amir142/Artflict-project
ben18-meet Jul 24, 2018
491e7c9
Fixed Isues
ben18-meet Jul 24, 2018
da911d0
Feed html mockup finished
may3825 Jul 25, 2018
69b7b7e
Updated models with posts
ben18-meet Jul 25, 2018
2db0391
Merge branch 'master' of https://github.com/Amir142/Artflict-project
ben18-meet Jul 25, 2018
b186c7f
simple working version
ben18-meet Jul 25, 2018
6ba95b0
login & style
may3825 Jul 25, 2018
8ba6b5c
login page html
nomy18-meet Jul 25, 2018
a225edd
models done
Jul 26, 2018
3158597
merge models
Jul 26, 2018
eaec1f7
merging
ben18-meet Jul 26, 2018
18ac784
synax err
ben18-meet Jul 26, 2018
f604cd6
login html changes
nomy18-meet Jul 26, 2018
adf29d9
Working Version
ben18-meet Jul 26, 2018
f1447eb
Merge branch 'master' of https://github.com/Amir142/Artflict-project
ben18-meet Jul 26, 2018
1383c95
comment
nomy18-meet Jul 26, 2018
c7aeb52
designing login page
ben18-meet Jul 26, 2018
b0cb30f
posting works
may3825 Jul 26, 2018
96b4a48
fixed posting
may3825 Jul 26, 2018
b32166d
add basic to push to heroku
Jul 26, 2018
8ebad29
added logout
ben18-meet Jul 26, 2018
a407bda
Merge branch 'master' of https://github.com/Amir142/Artflict-project
ben18-meet Jul 26, 2018
9369cca
add correct dev database uri
ben18-meet Jul 26, 2018
f4df43c
working routes
Jul 26, 2018
87b05e5
login page working
nomy18-meet Jul 26, 2018
4f37f0e
login page working
nomy18-meet Jul 26, 2018
61eb482
login layout
nomy18-meet Jul 26, 2018
c574a4f
need to work on the signup form
ben18-meet Jul 26, 2018
60d94a6
fuck this shit we outie
ben18-meet Jul 26, 2018
9c3e5cb
pushing feed
Jul 29, 2018
508ec1f
fixed date format
Jul 29, 2018
f5f3e92
fixed date format 2.0
Jul 29, 2018
448162d
fixed date format 2.1
Jul 29, 2018
c272a56
fixed date format 2.1
Jul 29, 2018
2ddeea5
changing the index page to the feed page
nomy18-meet Jul 29, 2018
1b30e8b
index to feed
nomy18-meet Jul 29, 2018
6d05220
Working on artist - story linking
ben18-meet Jul 29, 2018
ca63e1d
Checking artist linking
ben18-meet Jul 29, 2018
18bbf9b
Feed page cleanup
may3825 Jul 29, 2018
5813799
Feed page
may3825 Jul 29, 2018
1607e8f
Need to check art linkning
ben18-meet Jul 29, 2018
e7b5874
Merge branch 'master' of https://github.com/Amir142/Artflict-project …
ben18-meet Jul 29, 2018
21d762b
login / signup forms
Jul 29, 2018
70f0e2f
waiting for the register
nomy18-meet Jul 29, 2018
cedef71
fixed merge conflicts
Jul 29, 2018
219af9e
fixed merge conflicts 2
Jul 29, 2018
f954c21
merge c
ben18-meet Jul 29, 2018
d8921fd
aaa
Jul 29, 2018
a37e0a5
Merge branch 'master' of https://github.com/Amir142/Artflict-project …
ben18-meet Jul 29, 2018
e1b7b44
style conflict
Jul 30, 2018
9b181c8
Feed and post
may3825 Jul 30, 2018
ecb91bd
Adding add url modal
ben18-meet Jul 30, 2018
6b46302
login logic
Jul 30, 2018
f36bc7b
Adding add url modal
ben18-meet Jul 30, 2018
7858126
Blah
ben18-meet Jul 30, 2018
d60e244
Working post page
may3825 Jul 30, 2018
d97e8f4
feed and post
may3825 Jul 30, 2018
edc0420
F
ben18-meet Jul 30, 2018
02c3a5d
fd
ben18-meet Jul 30, 2018
46b5f68
Merging with master
ben18-meet Jul 30, 2018
fe12975
new feed and post
may3825 Jul 30, 2018
dc2a257
resolving merge conflict
ben18-meet Jul 30, 2018
7cc4c7c
working on the profile page
nomy18-meet Jul 30, 2018
596996a
Amir
Jul 30, 2018
f8f2e63
Profile page linking working
nomy18-meet Jul 30, 2018
b232ab3
Merge branch 'master' of https://github.com/Amir142/Artflict-project
nomy18-meet Jul 30, 2018
73f3b6e
Pulling
ben18-meet Jul 31, 2018
49c05ce
Pulling 2
ben18-meet Jul 31, 2018
4bedfaf
AddArt Working
ben18-meet Jul 31, 2018
23c2273
Merge branch 'master' of https://github.com/Amir142/Artflict-project
ben18-meet Jul 31, 2018
93b3ce7
Merge branch 'weekend_stash'
ben18-meet Jul 31, 2018
5def6cc
profile fun
Jul 31, 2018
65d4cdb
nomi and her push
Jul 31, 2018
a0a62de
Created view story html
ben18-meet Jul 31, 2018
cb51183
Created view story html and merge fixing
ben18-meet Jul 31, 2018
de83a41
ajax
Jul 31, 2018
6ae64a8
Working on main feed
ben18-meet Jul 31, 2018
2537f22
Redirecting from posts to main feed works
ben18-meet Aug 1, 2018
8d51ed7
Working on feed
may3825 Aug 1, 2018
a3c2e42
working on the nevbar
nomy18-meet Aug 1, 2018
3492e13
Add post design
ben18-meet Aug 1, 2018
4ab1875
Working version
ben18-meet Aug 1, 2018
3c29c01
basic cleaning and create layout.html
ben18-meet Aug 1, 2018
e714b06
big modif
ben18-meet Aug 1, 2018
72e9a80
Merge pull request #1 from Amir142/fix-master
ben18-meet Aug 1, 2018
f0b515c
Ready to push
may3825 Aug 1, 2018
45b2b79
connected backend and frontend w json
Aug 1, 2018
890abc7
fixed merge conflicts<<<<'
may3825 Aug 1, 2018
5b17f45
feeds css
may3825 Aug 1, 2018
ae0b6b5
perfect logic ma boiz
Aug 1, 2018
1542084
Working on image pages
ben18-meet Aug 1, 2018
55aa15f
merge fix
Aug 1, 2018
6cf1844
pushing login
Aug 1, 2018
969310b
Commit after pull
ben18-meet Aug 1, 2018
e547a0b
fixed commits
ben18-meet Aug 1, 2018
008cd89
added artist name to art piece
ben18-meet Aug 1, 2018
b0b2649
CSS for view story and post
ben18-meet Aug 2, 2018
015cb7b
fixing nav bar
Aug 2, 2018
422da30
Navbar
may3825 Aug 2, 2018
b62c67c
fixed navbar merge
may3825 Aug 2, 2018
5d25888
Working on landing page
ben18-meet Aug 2, 2018
73cdc16
fixed merge
ben18-meet Aug 2, 2018
8f98fde
Fixed Navbar
ben18-meet Aug 2, 2018
f646306
Deleted route for landing page
ben18-meet Aug 2, 2018
83d79de
profile progress
Aug 2, 2018
bd0e96f
Merge branch 'master' of github.com:Amir142/Artflict-project
Aug 2, 2018
f9f8dff
Merge branch 'master' into image
may3825 Aug 2, 2018
692db9b
landing page
may3825 Aug 2, 2018
4cb2e40
Working on profile
ben18-meet Aug 2, 2018
7431975
Merge pull request #2 from Amir142/image
ben18-meet Aug 4, 2018
40a61e6
Fixed views.py merge
ben18-meet Aug 4, 2018
5aca6eb
View story and profile Update
ben18-meet Aug 5, 2018
1da7851
landing page
may3825 Aug 5, 2018
ebaa8c3
Profile page work
ben18-meet Aug 5, 2018
f011947
pulled updated views and profile
Aug 5, 2018
43e2e69
Finished profile pic change
ben18-meet Aug 5, 2018
cab3541
Profile page working
ben18-meet Aug 5, 2018
7708a0a
Added profile navbar
ben18-meet Aug 5, 2018
f7c3fd0
new background
nomy18-meet Aug 5, 2018
fa87d01
pulling profile page
Aug 5, 2018
653e5f0
about us
may3825 Aug 5, 2018
082a0f8
merge conflict
Aug 5, 2018
18a4487
about us 2
may3825 Aug 5, 2018
de5d6e5
cOMmiting to push
may3825 Aug 5, 2018
5eca683
css about
may3825 Aug 5, 2018
a87c746
bg
nomy18-meet Aug 5, 2018
19aa3b6
mergin
Aug 5, 2018
b099162
Merge branch 'master' of github.com:Amir142/Artflict-project
Aug 5, 2018
7a163ee
solving layout conflicts
nomy18-meet Aug 5, 2018
8d7c364
Pulling working background
ben18-meet Aug 5, 2018
317ce74
Merge branch 'master' of https://github.com/Amir142/Artflict-project
ben18-meet Aug 5, 2018
0f8aba0
fixed background
nomy18-meet Aug 5, 2018
a03e0a0
merge meh
Aug 5, 2018
1561ddd
merge meh
Aug 5, 2018
6643d52
commit before merge
may3825 Aug 5, 2018
7e7f0c2
fixed merge changes
may3825 Aug 5, 2018
b2ed0c8
Merge branch 'master' of https://github.com/Amir142/Artflict-project
ben18-meet Aug 5, 2018
1d26e12
Working push version
ben18-meet Aug 5, 2018
038a5d4
FIxed profile paage forms
ben18-meet Aug 5, 2018
b0f3845
View story page design
ben18-meet Aug 5, 2018
776659a
Fixed form and routing bugs + added art to profile page
ben18-meet Aug 5, 2018
a4e7132
profile page
nomy18-meet Aug 6, 2018
7d35703
push modif
nomy18-meet Aug 6, 2018
8cb4ba9
fixed css links
nomy18-meet Aug 6, 2018
5537f6a
Merge branch 'master' into neomy/add-better-css-layout
nomy18-meet Aug 6, 2018
fbf92b3
Merge pull request #3 from Amir142/neomy/add-better-css-layout
nomy18-meet Aug 6, 2018
2ffbfb7
Merge branch 'master' into fixing_css_links
nomy18-meet Aug 6, 2018
7da5835
change titles
nomy18-meet Aug 6, 2018
8e9f370
Merge pull request #5 from Amir142/fixing_css_links
nomy18-meet Aug 6, 2018
0315d45
fixed blocks
may3825 Aug 6, 2018
305d49f
working w/o feed
Aug 6, 2018
c5c143a
new nevbar
nomy18-meet Aug 6, 2018
1318bab
Working nav +profile page
nomy18-meet Aug 6, 2018
f99746e
Pulling navbar
nomy18-meet Aug 6, 2018
1d7222f
third commit
may3825 Aug 6, 2018
d124864
third commit
may3825 Aug 6, 2018
b183bcf
new nevbar
nomy18-meet Aug 6, 2018
c12fc3c
Working nav +profile page
nomy18-meet Aug 6, 2018
f5817db
merge conflict with head
nomy18-meet Aug 6, 2018
a827f0c
aboutus page
may3825 Aug 6, 2018
23daa9f
resolving merge conflicts
nomy18-meet Aug 6, 2018
5d8e4ab
merging with master conflicts
nomy18-meet Aug 6, 2018
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ _mailinglist
docs/_build/
.vscode/

*.cfg

# Coverage reports
htmlcov/
.coverage
Expand Down
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn project:app
3 changes: 2 additions & 1 deletion instance/flask.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ BASEDIR = os.path.abspath(os.path.dirname(__file__))
TOP_LEVEL_DIR = os.path.abspath(os.curdir)
PROJECT_DIR = os.path.join(TOP_LEVEL_DIR, 'project')

SQLALCHEMY_DATABASE_URI = "sqlite:///%s" % os.path.join(PROJECT_DIR, 'project.db')
SQLALCHEMY_DATABASE_URI = 'sqlite:///%s' % os.path.join(PROJECT_DIR, 'project.db')


# Update later by using a random number generator and moving
# the actual key outside of the source code under version control
Expand Down
12 changes: 7 additions & 5 deletions project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@
app = Flask(__name__, instance_relative_config=True)
app.config.from_pyfile('flask.cfg')


db = SQLAlchemy(app)

login_manager = LoginManager(app)
login_manager.login_view = 'users.login'

from project.models import User
from project.models import User, Post

@login_manager.user_loader
def load_user(user_id):
return User.query.filter(User.id == int(user_id)).first()

return User.query.filter(User.id == int(user_id)).first()

# Blueprints
from project.users import users_bp

from project.add_post import post_bp
from project.profile import profile_bp
app.register_blueprint(users_bp)

app.register_blueprint(post_bp)
app.register_blueprint(profile_bp)

# General views
from . import views
Expand Down
71 changes: 71 additions & 0 deletions project/add_post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
from flask import (
Blueprint, redirect, render_template,
Response, request, url_for , session
)
from flask_login import login_user, login_required, logout_user, current_user
from project import db
from project.forms import PostForm, AddArtForm
from project.models import Post, User


post_bp = Blueprint('add_post', __name__)

@post_bp.route('/create_post', methods= ['GET', 'POST'])
@login_required
def add_post():
form = PostForm(request.form)
if request.method == 'POST':

title = form.title.data
text = form.text.data

test_result = test_add_post(form)

if test_result == "success":
post = Post(current_user.id, title, text)
db.session.add(post)
db.session.commit()
return redirect(url_for("feed"))
else:
data = {'err_msg':test_result}
return render_template('add_post.html',form = form, data = data)

else:
return render_template('add_post.html', form=form)

def test_add_post(form):
title = form.title.data
text = form.text.data
if not title or title == "":
return "post has to have a title"
if not text or text == "":
return "post has to have text"
return "success"

@post_bp.route('/add_art/<int:post_id>', methods= ['POST'])
@login_required
def add_art(post_id):
form = AddArtForm(request.form)
if request.method == 'POST':
if form.validate_on_submit():
post = Post.query.filter_by(id = post_id).first()
art_url = form.art_url.data
post.ArtURL = art_url
post.ArtistNotes = form.artist_notes.data
post.ArtistID = current_user.id
db.session.commit()
return redirect(url_for('feed'))
else:
return Response("<p>invalid form</p>")












26 changes: 21 additions & 5 deletions project/forms.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
from flask_wtf import Form
from wtforms import StringField, PasswordField
from wtforms import StringField, PasswordField, TextAreaField
from wtforms.validators import DataRequired, Length, EqualTo


class RegisterForm(Form):
username = StringField('Username', validators=[DataRequired(), Length(max=40)])
password = PasswordField('Password', validators=[DataRequired(), Length(max=40)])
confirm = PasswordField('Confirm Password', validators=[DataRequired(), EqualTo('password')])
displayname = StringField('Display Name', validators=[DataRequired(), Length(max=40)])
username = StringField('Username', validators=[DataRequired(), Length(max=16)])
password = PasswordField('Password', validators=[DataRequired(), Length(max=40)])
confirm_pass = PasswordField('Confirm Password', validators=[DataRequired(), Length(max=40)])


class LoginForm(Form):
username = StringField('Username', validators=[DataRequired(), Length(max=40)])
username = StringField('Username', validators=[DataRequired(), Length(max=16)])
password = PasswordField('Password', validators=[DataRequired(), Length(max=40)])

class PostForm(Form):
title = StringField('Title', validators=[DataRequired()])
text = TextAreaField('Text', validators=[DataRequired()])

class AddArtForm(Form):
art_url = StringField('ArtUrl', validators = [DataRequired()])
artist_notes = TextAreaField('Notes', validators = [DataRequired()])

class ProfilePicForm(Form):
profile_pic_url = StringField('URL', validators = [DataRequired()])

class ProfileBioForm(Form):
profile_bio = StringField('Change Bio', validators = [DataRequired()])


121 changes: 101 additions & 20 deletions project/models.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,117 @@
from project import db
from datetime import datetime

from sqlalchemy import and_, or_
from flask_login import UserMixin
from werkzeug.security import check_password_hash, generate_password_hash


class User(UserMixin, db.Model):
__tablename__ = "users"
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
username = db.Column(db.String, unique=True, nullable=False)
displayname = db.Column(db.String)
#email = db.Column(db.String, unique=True, nullable=False)
bio = db.Column(db.String, default = "Hi, i'm using Artflict!")
profile_pic_url = db.Column(db.String, nullable=True)
password_hash = db.Column(db.String, nullable=False)

def __init__(self, username, displayname, password):
self.username = username
self.displayname = displayname
self.set_password(password)

def set_password(self, password):
self.password_hash = generate_password_hash(password)

def check_password(self, password):
return check_password_hash(self.password_hash, password)

def get_followers(self):
get_followers = Follower.query.filte_by(followedID = self.id)
return get_followers

def get_followed(self):
get_followed = Follower.query.filte_by(followerID = self.id)
return get_followed

def __repr__(self):
return 'User %d %s' % (self.id, self.username)

class Post(db.Model):
__tablename__='posts'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
AuthorID = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
ArtURL = db.Column(db.String)
ArtistID = db.Column(db.Integer, db.ForeignKey('users.id'))
ArtistNotes = db.Column(db.String)
Title = db.Column(db.String(20), nullable=False)
Text = db.Column(db.String, nullable=False)
Rating = db.Column(db.Integer)
Date = db.Column(db.String, nullable=False)

def __init__(self, AuthorID, Title, Text):
self.AuthorID = AuthorID
self.Title = Title
self.Text = Text
self.Date = self.format_date()
self.Rating = 0

def relate(self):
userid = current_user.id
getpostlike = Like.query.filter_by(postID = self.id).filter_by(UserID = userid).first()
if getpostlike is None:
add_like = Like(userid. self.id)
db.session.add(add_like)
else:
db.session.delete(getpostlike)

self.get_rating()
db.session.commit()

__tablename__ = "users"
def get_rating(self):
getlikes = Like.query.filter(postID == self.id).all()
self.Rating = len(getlikes)

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
username = db.Column(db.String, unique=True, nullable=False)
password_hash = db.Column(db.String, nullable=False)
def format_rating(self):
rating = float(self.Rating)
if rating < 1000:
return str(rating)
elif rating < 1000000:
new_rating = round(rating / 1000, 1)
return new_rating + "K"
elif rating < 1000000000:
new_rating = round(rating / 1000000, 1)
return new_rating + "M"
else:
return "LOTS"

def __init__(self, username, password):
self.username = username
self.set_password(password)
def format_date(self):
now = datetime.now()
return str(now.month) + " - " + str(now.day) + " - " + str(now.year)

def set_password(self, password):
self.password_hash = generate_password_hash(password)
def get_description(self):
return self.Text[:200] + "..."

def check_password(self, password):
return check_password_hash(self.password_hash, password)

def __repr__(self):
return 'User %d %s' % (self.id, self.username)
def __repr__(self):
return "post " + str(self.id) + " " + str(self.Title) + " " + str(self.Text)

class Like(db.Model):
__tablename__='likes'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
userID = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
postID = db.Column(db.Integer, db.ForeignKey('posts.id'), nullable=False)

# TODO: Create your other models here
class YourModel(db.Model):

__tablename__ = "yourmodel"
def __init__(self, userID, postID):
self.userID = userID
self.postID = postID

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
class Follower(db.Model):
__tablename__ = 'followers'
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
followerID = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
followedID = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)

# fill in the rest of your fields and methods!
def __init__(self, followerID, followedID):
self.followerID = followerID
self.followedID = followedID
38 changes: 38 additions & 0 deletions project/profile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from flask import (
Blueprint, redirect, render_template,
Response, request, url_for , session,
abort
)
from flask_login import login_required, current_user
from project import db
from project.models import User, Post, Like
from . import app
from project.forms import ProfilePicForm, ProfileBioForm

profile_bp = Blueprint('profile', __name__)

@profile_bp.route('/change_pic', methods= ['POST'])
@login_required
def change_pic():
form = ProfilePicForm(request.form)
if request.method == 'POST':
if form.validate_on_submit():
user = User.query.filter_by(id = current_user.id).first()
user.profile_pic_url = form.profile_pic_url.data
db.session.commit()
return redirect(url_for('profile', username = current_user.username))
else:
return Response("<p>invalid form</p>")

@profile_bp.route('/change_bio', methods= ['POST'])
@login_required
def change_bio():
form = ProfileBioForm(request.form)
if request.method == 'POST':
if form.validate_on_submit():
user = User.query.filter_by(id = current_user.id).first()
user.bio = form.profile_bio.data
db.session.commit()
return redirect(url_for('profile', username = current_user.username))
else:
return Response("<p>invalid form</p>")
Loading