Skip to content

Commit

Permalink
Merge pull request #21 from Lemmah/develop
Browse files Browse the repository at this point in the history
Application Functionality on UI: using Jinja -> Attempting first build on default branch
  • Loading branch information
Lemmah authored Jul 26, 2017
2 parents e8cef0b + 32c7201 commit 6762083
Show file tree
Hide file tree
Showing 14 changed files with 510 additions and 183 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ in your terminal and if its not greater than or equal to 3.5, you're not in big

### Installing

Now, you have python3 and a way of running a virtual environment. Lets set up the project environment.
Now, you have python3 and a way of running a virtual environment. Lets set up the project environment.(remember we're still in the app directory)

1. Create your virtual environment. Usually, without any wrappers:
```
Expand All @@ -39,16 +39,23 @@ pip install -r requirements.txt
```

This is enough to get you started.
**More instructions are coming up as the project advances**.
You can now run the application using:
`gunicorn runapp:app --log-file -`
or
`python runapp.py`

## Running the tests

Automated tests are yet to be done, this is coming up too.
## Running the tests

Easy, just:
`pytest app/`

## Deployment

This system is bound to be deployed in Heroku...deployment instructions are coming up soon too.
This app is ready for Heroku. You can deploy your copy of this app by:
`heroku create <your_url_name>` (where <your_url_name> is what you want to call your app)
`git push heroku master`
..and boom, you're done! You can chat me on gitter in case of any problems.(gitter link is on badge above)

## Built With

Expand All @@ -57,7 +64,7 @@ This system is bound to be deployed in Heroku...deployment instructions are comi

## Contributing

Contributing to this project is closed for the first month. Thereafter, you can make your pull request.
Contributing to this project is closed for the first month. Thereafter, you can make your pull request. Three more days before you can make your pull request. :D

## Versioning

Expand Down
30 changes: 13 additions & 17 deletions app/bucketlist/bucketlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,33 @@ class BucketList:

def __init__(self, name, details=None, items=None, owner=None):
''' Constructing and instance of the object '''
# Every bucketlist must have an owner
if owner is None:
raise Exception("Every bucketlist must have an owner")
self.name = name
self.details = details
if items is not None:
self.items = items
else:
self.items = []
self.items = []
self.owner = owner

@property
def bucket_id(self):
return "{}-{}".format(self.owner, self.name)

def add_item(self, item_details, owner):
# initialize an instance of a BucketListItem
item_name = item_details[0]
# ensure that items does not exist in items
if item_name in self.items:
raise Exception("{} already exists!".format(item_name))
self.items.append(item_name)
new_item = BucketListItem(*item_details, bucketlist=owner)
self.items.append(new_item)
return (new_item, "{} added successfully".format(item_name))

def remove_item(self, item_name):
if item_name not in self.items:
raise Exception("{} does not exist.".format(item_name))
self.items.remove(item_name)
def remove_item(self, bucketlist_item):
if bucketlist_item not in self.items:
raise Exception("{} does not exist.".format(bucketlist_item))
self.items.remove(bucketlist_item)
# the class instance of bucketlist item will be garbage collected
return "{} removed successfully".format(item_name)
return "{} item has been removed successfully".format(bucketlist_item)

def update_item(self, target_item, new_details):
''' Update bucketlist items '''
target_item.name, target_item.category, target_item.description = (new_details)
return "{} bucketlist item has been update accordingly.".format(target_item.name)


def __repr__(self):
''' Represent item by name '''
Expand Down
27 changes: 7 additions & 20 deletions app/bucketlist/bucketlist_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,16 @@ def add_bucketlist(self, bucketlist_details):
if bucketlist_name in self.available_bucketlists:
raise Exception("A bucketlist with the name {} already exists")
# add name of new bucketlist to list of available bucketlists
self.available_bucketlists.append(bucketlist_details[0])
new_bucketlist = BucketList(*bucketlist_details, owner=self.user)
return (new_bucketlist, "{} bucketlist has been created".format(bucketlist_name))
self.available_bucketlists.append(new_bucketlist)
return (new_bucketlist, "{} bucketlist has been created".format(new_bucketlist))

def rename_bucketlist(self, target_bucketlist, new_name):
''' Functionality to rename a bucketlist '''
old_name = target_bucketlist.name
# change name in list of available bucketlists
for bucketlist in self.available_bucketlists:
if bucketlist == target_bucketlist.name:
bucketlist = new_name
# change name in bucketlist instance
target_bucketlist.name = new_name
return "{} bucketlist has been renamed to {}".format(old_name, new_name)

def change_bucketlist_details(self, target_bucketlist, new_bucketlist_description):
''' Functionality to update bucketlist description '''
target_bucketlist.description = new_bucketlist_description
def change_bucketlist_details(self, target_bucketlist, new_bucketlist_details):
''' Functionality to update bucketlist details '''
target_bucketlist.name, target_bucketlist.details = (new_bucketlist_details)
return "{} has been updated accordingly".format(target_bucketlist.name)

def delete_bucketlist(self, bucketlist):
''' Functionality to delete bucketlist '''
target_bucketlist = bucketlist.name
self.available_bucketlists.remove(bucketlist.name)
bucketlist.name = None
return "Successfully deleted {} bucketlist".format(target_bucketlist)
self.available_bucketlists.remove(bucketlist)
return "Successfully deleted {} bucketlist".format(bucketlist)
10 changes: 5 additions & 5 deletions app/bucketlist/bucketlist_item.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# A bucketlist item and all it's attributes


class BucketListItem:
''' Tis is the bucketlist item object '''
''' This is the bucketlist item object '''

def __init__(self, name, category, description=None, status=None, bucketlist=None):
''' Constructing the bucketlist item while handling possible exceptions '''
# Ensure item belongs to a bucketlist
if bucketlist is None:
raise Exception("BucketList item must belong to a bucketlist")
self.name = name
self.category = category
self.description = description
Expand All @@ -25,3 +21,7 @@ def change_status(self):
else:
self.status = "done"
return self.status

def __repr__(self):
''' Item representation '''
return self.name
9 changes: 9 additions & 0 deletions app/static/css/custom.css
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
body {
display: flex;
min-height: 100vh;
flex-direction: column;
}

main {
flex: 1 0 auto;
}

19 changes: 7 additions & 12 deletions app/templates/base_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@
</div>
</nav>
</header>

<!-- Defining a bucketlist -->
<div id="bucketlist_definition" class="modal">
<div class="modal-content">
<h4>Bucket list?</h4>
<p>A bucket list is, by definition, a list of things that you want to do before you die. The term gained in popularity after the 2007 movie “The Bucket List” where Morgan Freeman and Jack Nicholson (both of whose characters are dying of cancer) create a bucket list of things to do before they die – and then actually do them. </p>
</div>
<div class="modal-footer">
<a href="" class="btn modal-action modal-close waves-effect waves-teal green darken-3">Ok, got it.</a>
</div>
</div>

<!-- The main body -->
<section>
{% block body %}{% endblock %}
Expand Down Expand Up @@ -73,6 +61,13 @@ <h4>Bucket list?</h4>
$("#register_tab").addClass("active");
});
});
// Intialize dropdown
$('.dropdown-button').dropdown();
// Initialize select
$(document).ready(function() {
$('select').material_select();
});

</script>
</body>
</html>
138 changes: 103 additions & 35 deletions app/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,128 @@
{% block title %}Dream Buckets | Dashboard{% endblock %}
{% block nav_menu_items %}
<ul id="nav-mobile" class="left hide-on-med-and-down">
<li><a href="#bucketlist_definition" class="waves-effect waves-teal btn-flat">Bucket List?</a></li>
</ul>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li><a href="#" class="waves-effect waves-teal btn-flat">{{ username }}</a></li>
<li><a href="/logout/" class="waves-effect waves-teal btn-flat">LogOut</a></li>
</ul>
<ul class="side-nav" id="mobile-demo">
<li><a href="#bucketlist_definition">BucketList?</a></li>
<li><a href="/logout/">Logout</a></li>
</ul>
{% endblock %}
{% block body %}
<div class="container">
<div class="row center">
<p class="flow-text">The ultimate bucket list!</p>
</div>
<p class="flow-text">Before you die...</p>
<div class="col s12 m4"></div>
<div class="col s12 m4 center card ">
{% for message in get_flashed_messages() %}
<p class="red-text">{{ message }}</p>
{% endfor %}
</div>
<div class="col s12 m4"></div>
</div>
<div class="row">
<ul class="collection">
<li class="collection-item avatar">
<i class="material-icons circle">accessibility</i>
<span class="title">Run a marathon</span>
<p>
<span class="bcategory blue-text">Health and Fitness</span><br>
Dudu goals! I need a six pack...feeling good about myself. YOLO!
</p>
<a href="#!" class="btn waves-teal waves-teal secondary-content"><i class="material-icons">edit</i></a>
</li>
{% if not no_bucketlists %}
{% for bucketlist in session_user.available_bucketlists %}
<li class="collection-item avatar">
<i class="material-icons circle green">insert_chart</i>
<span class="title">Enroll in a phd program</span>
<p> <span class="bcategory blue-text"> Education and Career </span><br>
There is a feeling that I need a greater understanding of what I do because it's what I love. I need not an Ivy league school but at least I better get going.
<span class="title">{{ bucketlist.name }}</span>
<p> <span class="blue-text"> {{ bucketlist.details }}</span><br>
{% for item in bucketlist.items %}
<div class="chip">
{{ item }}
</div>
{% endfor %}
</p>
<a href="#!" class="btn waves-teal waves-teal secondary-content"><i class="material-icons">edit</i></a>
</li>
<li class="collection-item avatar">
<i class="material-icons circle red">play_arrow</i>
<span class="title">Visit Japanese Islands</span>
<p> <span class="bcategory blue-text"> Entertainment </span><br>
Japanese islands are an interesting place to go to. Ok, I don't know but I find this very interesting. I also want to see Hong Kong.
</p>
<a href="#!" class="btn waves-teal waves-teal secondary-content"><i class="material-icons">edit</i></a>
</li>
<!-- Dropdown of Options available to a bucketlist -->

<div class="fixed-action-btn horizontal secondary-content">
<a class="btn-floating btn-large green">
<i class="large material-icons">settings</i>
</a>
<ul>
<li><a href="bucketlists/{{ bucketlist }}/delete/" class="btn-floating red tooltipped" data-position="top" data-delay="10" data-tooltip="Delete Bucketlist"><i class="material-icons">delete</i></a></li>
<li><a href="bucketlists/{{ bucketlist }}/" class="btn-floating green tooltipped" data-position="top" data-delay="10" data-tooltip="Manage Items"><i class="material-icons">note_add</i></a></li>
<li><a href="#edit_bucketlist" class="btn-floating blue tooltipped" data-position="top" data-delay="10" data-tooltip="Edit Bucketlist"><i class="material-icons">mode_edit</i></a></li>
</ul>
</div>
<!-- Form for editing a Bucketlist: it's a modal! -->
<div id="edit_bucketlist" class="modal">
<div class="modal-content">
<h4>Edit {{ bucketlist.name }}</h4>
<div id="create_bucketlist" class="col s12">
<form class="col s12" method="post" action="bucketlists/{{ bucketlist.name }}/update/">
<div class="input-field col s12">
<i class="material-icons prefix">assignment</i>
<input id="icon_prefix" type="text" name="bucketlist_name" value="{{ bucketlist.name }}" required>
<label for="icon_prefix">Bucketlist Name</label>
</div>
<div class="input-field col s12">
<i class="material-icons prefix">assessment</i>
<textarea id="textarea1" class="materialize-textarea" name="bucketlist_desc">{{ bucketlist.details }}</textarea>
<label for="icon_prefix">Bucketlist Description</label>
</div>
</div>
</div>
<div class="modal-footer">
<a href="" class="left btn modal-action modal-close waves-effect waves-teal red darken-3"><i class="material-icons right">cancel</i>Cancel</a>
<button class="btn waves-teal green darken-3"><i class="material-icons right">done_all</i>Update</button>
</div>
</form>
</div>
{% endfor %}
{% else %}
<li class="collection-item avatar">
<div class="center">
<br><br>
<p class="flow-text"> There are no bucketlists in here... </p><br><br>
<p><a onclick="$('.tap-target').tapTarget('open')" class="waves-effect waves-light btn green">Create First Bucketlist</a></p>
<br><br>
</div>
</li>
{% endif %}
</ul>
</div>
</div>
<!-- Super Add Button: it's a tap target -->
<div class="fixed-action-btn">
<a id="menu" class="waves-effect waves-light btn btn-floating btn-large green" href="#create_bucketlist">
<i class="material-icons">add</i>
</a>
</div>

<!-- Welcome message: it's the tap content -->
<div class="tap-target green" data-activates="menu">
<div class="tap-target-content white-text">
<h5>The Super Add Button</h5>
<p class="white-text">Welcome, {{ username }}. We're glad that you're creating your first bucketlist here. You will be using this button to add more bucketlists and even add items to a bucketlist. Happy adventure!</p>
</div>
</div>

<!-- Adding and editing options -->
<div class="fixed-action-btn">
<a href="#" class="btn-floating green btn-large"><i class="large material-icons">add</i></a>
<ul>
<li><a href="#" class="btn-floating yellow "><i class="large material-icons">insert_chart</i></a></li>
<li><a href="#" class="btn-floating blue "><i class="large material-icons">format_quote</i></a></li>
<li><a href="#" class="btn-floating green"><i class="large material-icons">publish</i></a></li>
<li><a href="#" class="btn-floating orange"><i class="large material-icons">attach_file</i></a></li>
</ul>
<!-- Form for adding Bucketlist: it's a modal! -->
<div id="create_bucketlist" class="modal">
<div class="modal-content">
<h4>Enter Bucketlist Details</h4>
<div id="create_bucketlist" class="col s12">
<form class="col s12" method="post" action="create_bucketlist/">
<div class="input-field col s12">
<i class="material-icons prefix">assignment</i>
<input id="icon_prefix" type="text" name="bucketlist_name" required>
<label for="icon_prefix">Bucketlist Name</label>
</div>
<div class="input-field col s12">
<i class="material-icons prefix">assessment</i>
<textarea id="textarea1" class="materialize-textarea" name="bucketlist_desc"></textarea>
<label for="icon_prefix">Bucketlist Description</label>
</div>
</div>
</div>
<div class="modal-footer">
<a href="" class="left btn modal-action modal-close waves-effect waves-teal red darken-3"><i class="material-icons right">cancel</i>Cancel</a>
<button class="btn waves-teal green darken-3"><i class="material-icons right">add</i>Create</button>
</div>
</form>
</div>
{% endblock %}
Loading

0 comments on commit 6762083

Please sign in to comment.