Skip to content

Commit

Permalink
marker
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshes committed Mar 30, 2016
1 parent b9b375d commit 417b677
Show file tree
Hide file tree
Showing 112 changed files with 904 additions and 18,392 deletions.
155 changes: 3 additions & 152 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,155 +1,6 @@
Flask App (User app)
WishList Application
==================================

What is this?
-------------
This application includes a User model that is compatible with [Flask Login](https://flask-login.readthedocs.org).
We've also included a migration script which depends on [Flask Migrate](https://flask-migrate.readthedocs.org)
Web application created with Flask and AngularJS.

This is a
[Flask](http://flask.pocoo.org/) app that can be deployed to [Heroku](https://www.heroku.com/).

It is based on [flask_heroku](github.com/zachwill/flask_heroku)

It follows the structure from the [Flask megatutorial](http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world)



Prerequisites
-------------

It is assumed that you've installed the [heroku toolbelt](http://toolbelt.heroku.com)

Instructions
------------

Clone the repo.

git clone git@github.com:info3180/demo_user_app.git
cd flask_app

To clear the git history, remove the .git/ folder

rm -rf .git/


For your convenience, the project ships with a virtualenv script which means you
can quickly create a virtual environment using the following commands

python virtualenv.py --no-site-packages venv
source venv/bin/activate


Installing Packages
--------------------

### pip

Then, let's get the requirements installed in your isolated test
environment.

$ pip install -r requirements.txt


Running Your Application
------------------------

Activate your virtualenv

source venv/bin/activate

Now, you can run the application locally.

python run.py


Deploying
---------

If you haven't [signed up for Heroku](https://api.heroku.com/signup), go
ahead and do that. You should then be able to [add your SSH key to
Heroku](http://devcenter.heroku.com/articles/quickstart), and also
`heroku login` from the commandline.

Now, to upload your application, you'll first need to do the
following -- and obviously change `app_name` to the name of your
application:

heroku create app_name -s cedar

And, then you can push your application up to Heroku.

git push heroku master
heroku scale web=1

Finally, we can make sure the application is up and running.

heroku ps

Now, we can view the application in our web browser.

heroku open

And, to deactivate `virtualenv` (once you've finished coding), you
simply run the following command:

deactivate


Next Steps
----------

After you've got your application up and running, there a couple next
steps you should consider following.

1. Create a new `README.md` file.
2. Add your Google Analytics ID to the `base.html` template.
3. Adjust the `author` and `description` `<meta>` tags in the
`base.html` template.
4. Change the `humans.txt` and `favicon.ico` files in the `static`
directory.
5. Change the `apple-touch` icons in the `static` directory.


Reactivating the Virtual Environment
------------------------------------

If you haven't worked with `virtualenv` before, you'll need to
reactivate the environment everytime you close or reload your terminal.

$ source venv/bin/activate

If you don't reactivate the environment, then you'll probably receive a
screen full of errors when trying to run the application locally.


Adding Requirements
-------------------

In the course of creating your application, you may find yourself
installing various Python modules with `pip` -- in which case you'll
need to update the `requirements.txt` file. One way that this can be
done is with `pip freeze`.

$ pip freeze > requirements.txt


Custom Domains
--------------

If your account is verified -- and your credit card is on file -- you
can also easily add a custom domain to your application.

$ heroku addons:add custom_domains
$ heroku domains:add www.mydomainname.com

You can add a [naked domain
name](http://devcenter.heroku.com/articles/custom-domains), too.

$ heroku domains:add mydomainname.com

Lastly, add the following A records to your DNS management tool.

75.101.163.44
75.101.145.87
174.129.212.2
Justen Morgan - 620070138
4 changes: 2 additions & 2 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import os

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret'

app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://project2:project2@localhost/projectdb"
#app.config['SQLALCHEMY_DATABASE_URI'] =
db = SQLAlchemy(app)
db.create_all()

from app import views,models
from app import views,models
29 changes: 23 additions & 6 deletions app/models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from . import db
import random
class User(db.Model):
__tablename__ = 'persons'
id = db.Column(db.Integer, primary_key=True)
image = db.Column(db.String(255))
first_name = db.Column(db.String(80))
last_name = db.Column(db.String(80))
username = db.Column(db.String(80), unique=True)
password = db.Column(db.String(255), unique=True)
email = db.Column(db.String(120), unique=True)
addon = db.Column(db.DateTime,nullable=False)
wishes = db.relationship('Wish',backref='user',lazy='dynamic')
tokens = db.relationship('Token',backref='user',lazy='dynamic')

def __init__(self,image,first_name,last_name,username,password,email,addon):
self.image = image
def __init__(self,first_name,last_name,username,password,email,addon):
self.first_name = first_name
self.last_name = last_name
self.username = username
Expand Down Expand Up @@ -42,16 +42,16 @@ class Wish(db.Model):
__tablename__ = 'wishes'
id = db.Column(db.Integer, primary_key=True)
userid = db.Column(db.Integer, db.ForeignKey('persons.id'))
image = db.Column(db.String(255))
url = db.Column(db.String(255))
name = db.Column(db.String(255))
description = db.Column(db.String(255))
status = db.Column(db.Boolean)
addon = db.Column(db.DateTime,nullable=False)


def __init__(self,userid,image,name,description,status,addon):
def __init__(self,userid,url,name,description,status,addon):
self.userid = userid
self.image = image
self.url = url
self.name = name
self.description = description
self.status = status
Expand All @@ -65,5 +65,22 @@ def get_id(self):

def __repr__(self):
return '<Wish %r>' % (self.name)

class Token(db.Model):
__tablename__ = 'tokens'
userid = db.Column(db.Integer, db.ForeignKey('persons.id'))
token = db.Column(db.String(255), primary_key=True)

def __init__(self,userid):
self.userid = userid
tokens = db.session.query(Token).all()
tokens = map(lambda x:x.token,tokens)
token = tokenGenerate()
while token in tokens:
token = tokenGenerate()
self.token = token

def tokenGenerate():
return ''.join(random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for i in range (16))


21 changes: 21 additions & 0 deletions app/static/bower_components/angular-cookies/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "angular-cookies",
"version": "1.5.3",
"license": "MIT",
"main": "./angular-cookies.js",
"ignore": [],
"dependencies": {
"angular": "1.5.3"
},
"homepage": "https://github.com/angular/bower-angular-cookies",
"_release": "1.5.3",
"_resolution": {
"type": "version",
"tag": "v1.5.3",
"commit": "14746d4663eaa01a969e1ce149a4fe177fa95f1c"
},
"_source": "git://github.com/angular/bower-angular-cookies.git",
"_target": "^1.5.3",
"_originalSource": "angular-cookies",
"_direct": true
}
68 changes: 68 additions & 0 deletions app/static/bower_components/angular-cookies/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# packaged angular-cookies

This repo is for distribution on `npm` and `bower`. The source for this module is in the
[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngCookies).
Please file issues and pull requests against that repo.

## Install

You can install this package either with `npm` or with `bower`.

### npm

```shell
npm install angular-cookies
```

Then add `ngCookies` as a dependency for your app:

```javascript
angular.module('myApp', [require('angular-cookies')]);
```

### bower

```shell
bower install angular-cookies
```

Add a `<script>` to your `index.html`:

```html
<script src="/bower_components/angular-cookies/angular-cookies.js"></script>
```

Then add `ngCookies` as a dependency for your app:

```javascript
angular.module('myApp', ['ngCookies']);
```

## Documentation

Documentation is available on the
[AngularJS docs site](http://docs.angularjs.org/api/ngCookies).

## License

The MIT License

Copyright (c) 2010-2015 Google, Inc. http://angularjs.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Loading

0 comments on commit 417b677

Please sign in to comment.