Skip to content

Commit

Permalink
add bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
timini committed Mar 23, 2016
1 parent c15f123 commit 0c6c83c
Show file tree
Hide file tree
Showing 35 changed files with 473 additions and 2 deletions.
8 changes: 8 additions & 0 deletions client/app/models/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import DS from 'ember-data';

export default DS.Model.extend({
text: DS.attr('string'),
user: DS.belongsTo('user'),
created_at: DS.attr('date'),
updated_at: DS.attr('date'),
});
6 changes: 6 additions & 0 deletions client/app/models/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import DS from 'ember-data';

export default DS.Model.extend({
username: DS.attr('string'),
email: DS.attr('string'),
});
7 changes: 7 additions & 0 deletions client/app/routes/root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Ember from 'ember';

export default Ember.Route.extend({
model() {
return this.store.findAll('comment');
}
});
7 changes: 7 additions & 0 deletions client/app/routes/users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Ember from 'ember';

export default Ember.Route.extend({
model() {
return this.store.findAll('user');
}
});
43 changes: 42 additions & 1 deletion client/app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
<h1>chit chat</h1>
<div class="container">
<!-- Static navbar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Chitter Chatter</a>
</div>
{{!--
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="./">Default <span class="sr-only">(current)</span></a></li>
<li><a href="../navbar-static-top/">Static top</a></li>
<li><a href="../navbar-fixed-top/">Fixed top</a></li>
</ul>
</div><!--/.nav-collapse -->
--}}
</div><!--/.container-fluid -->
</nav>
{{outlet}}
</div><!-- .container -->
12 changes: 12 additions & 0 deletions client/app/templates/root.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{outlet}}

{{#each model as |comment|}}
<p>
{{comment.text}}
{{comment.createdAt}}
{{comment.updatedAt}}
{{comment.user.username}}
{{comment.user.email}}
</p>
{{/each}}
{{bs-input}}
3 changes: 2 additions & 1 deletion client/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"ember": "~2.4.1",
"ember-cli-shims": "0.1.0",
"ember-cli-test-loader": "0.2.2",
"ember-qunit-notifications": "0.1.0"
"ember-qunit-notifications": "0.1.0",
"bootstrap": "~3.3.5"
}
}
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"devDependencies": {
"broccoli-asset-rev": "^2.2.0",
"ember-ajax": "0.7.1",
"ember-bootstrap": "0.6.4",
"ember-cli": "2.4.2",
"ember-cli-app-version": "^1.0.0",
"ember-cli-babel": "^5.1.5",
Expand Down
12 changes: 12 additions & 0 deletions client/tests/unit/controllers/users-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('controller:users', 'Unit | Controller | users', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

// Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.subject();
assert.ok(controller);
});
12 changes: 12 additions & 0 deletions client/tests/unit/models/comment-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('comment', 'Unit | Model | comment', {
// Specify the other units that are required for this test.
needs: []
});

test('it exists', function(assert) {
let model = this.subject();
// let store = this.store();
assert.ok(!!model);
});
18 changes: 18 additions & 0 deletions client/tests/unit/models/user-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('user', 'Unit | Model | user', {
// Specify the other units that are required for this test.
needs: []
});

test('it exists', function(assert) {
let model = this.subject();
// let store = this.store();
assert.ok(!!model);
});

test('has usernname and email', function(assert){
let model = this.suject();
assert.ok(model.username);
assert.ok(model.email);
});
12 changes: 12 additions & 0 deletions client/tests/unit/models/users-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { moduleForModel, test } from 'ember-qunit';

moduleForModel('users', 'Unit | Model | users', {
// Specify the other units that are required for this test.
needs: []
});

test('it exists', function(assert) {
let model = this.subject();
// let store = this.store();
assert.ok(!!model);
});
11 changes: 11 additions & 0 deletions client/tests/unit/routes/root-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('route:root', 'Unit | Route | root', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
});
11 changes: 11 additions & 0 deletions client/tests/unit/routes/users-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { moduleFor, test } from 'ember-qunit';

moduleFor('route:users', 'Unit | Route | users', {
// Specify the other units that are required for this test.
// needs: ['controller:foo']
});

test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
});
Empty file added server/api/chat/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions server/api/chat/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin
from chat.models import Comment

# Register your models here.
class CommentAdmin(admin.ModelAdmin):
list_display = ('text', 'user', 'created_at', 'updated_at')

admin.site.register(Comment, CommentAdmin)
5 changes: 5 additions & 0 deletions server/api/chat/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ChatConfig(AppConfig):
name = 'chat'
36 changes: 36 additions & 0 deletions server/api/chat/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-03-23 10:39
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='DateMixin',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
),
migrations.CreateModel(
name='Comment',
fields=[
('datemixin_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='chat.DateMixin')),
('text', models.CharField(max_length=255)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
bases=('chat.datemixin',),
),
]
Empty file.
12 changes: 12 additions & 0 deletions server/api/chat/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.db import models
from django.contrib.auth.models import User


class DateMixin(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)


class Comment(DateMixin):
text = models.CharField(max_length=255)
user = models.ForeignKey(User)
8 changes: 8 additions & 0 deletions server/api/chat/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from chat.models import Comment
from rest_framework import serializers


class CommentSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Comment
fields = ('text', 'user', 'created_at', 'updated_at')
3 changes: 3 additions & 0 deletions server/api/chat/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
12 changes: 12 additions & 0 deletions server/api/chat/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from chat.models import Comment
from rest_framework import viewsets

from chat.serializers import CommentSerializer


class CommentViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows comments to be viewed or edited.
"""
queryset = Comment.objects.all().order_by('-created_at')
serializer_class = CommentSerializer
Empty file added server/api/main/__init__.py
Empty file.
Loading

0 comments on commit 0c6c83c

Please sign in to comment.