Skip to content

Commit

Permalink
Merge branch 'version-1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Strzelczyk committed Jun 18, 2018
2 parents 94cb985 + f5ae0eb commit d53bbc5
Show file tree
Hide file tree
Showing 50 changed files with 905 additions and 133 deletions.
2 changes: 0 additions & 2 deletions palanaeum/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ def ready(self):
['git', 'rev-parse', '--verify', 'HEAD', '--short'],
cwd=settings.BASE_DIR, universal_newlines=True
).strip()
print(self.version, "THIS HAPPENS!!!!!")
except (FileNotFoundError, subprocess.CalledProcessError):
# No git installed or we're not a git instance at all
# We generate a random version tag
signs = set(string.hexdigits.lower())
self.version = 'r' + "".join(random.sample(signs, 6))

7 changes: 6 additions & 1 deletion palanaeum/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.forms.widgets import DateInput
from django.utils.translation import ugettext_lazy as _

from .models import UserSettings, Event, Entry, RelatedSite
from .models import UserSettings, Event, Entry, RelatedSite, UsersEntryCollection


class UserCreationFormWithEmail(UserCreationForm):
Expand Down Expand Up @@ -130,6 +130,11 @@ class Meta:
fields = ('name', 'url', 'image', 'order')


class UsersEntryCollectionForm(ModelForm):
class Meta:
model = UsersEntryCollection
fields = ('name', 'description', 'public')

class GeneralConfig(Form):
page_title = CharField(max_length=100, label=_('Page name'))
index_hello = CharField(max_length=1000, label=_('Index welcome text'),
Expand Down
27 changes: 27 additions & 0 deletions palanaeum/migrations/0002_auto_20180502_1627.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 2.0.4 on 2018-05-02 16:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('palanaeum', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='usersentrycollection',
name='starred',
),
migrations.AddField(
model_name='usersentrycollection',
name='description',
field=models.TextField(default=''),
),
migrations.AddField(
model_name='usersentrycollection',
name='entries',
field=models.ManyToManyField(related_name='collections', to='palanaeum.Entry'),
),
]
62 changes: 39 additions & 23 deletions palanaeum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.contrib.postgres.indexes import GinIndex
from django.core.exceptions import PermissionDenied
from django.core.files.uploadedfile import UploadedFile
from django.db import models, IntegrityError, connection
from django.db import models, connection
from django.db.models import Max, Count, Q
from django.urls import reverse
from django.utils import timezone
Expand Down Expand Up @@ -175,8 +175,8 @@ def created_by_html(self):
def save(self, *args, **kwargs):
self.modified_date = timezone.now()
request = get_request()
if request and hasattr(request, 'user'):
self.modified_by = get_request().user
if request and hasattr(request, 'user') and isinstance(request.user, User):
self.modified_by = request.user
super(Content, self).save(*args, **kwargs)


Expand Down Expand Up @@ -346,6 +346,20 @@ def __str__(self):
def get_absolute_url(self):
return reverse('view_event', args=(self.id, slugify(self.name)))

def get_next_url(self):
next_event = Event.all_visible.filter(date__lte=self.date)\
.exclude(pk=self.pk).values_list("id", "name").first()

if next_event:
return reverse('view_event', args=(next_event[0], slugify(next_event[1])))

def get_prev_url(self):
prev_event = Event.all_visible.filter(date__gte=self.date)\
.exclude(pk=self.pk).values_list("id", "name").last()

if prev_event:
return reverse('view_event', args=(prev_event[0], slugify(prev_event[1])))

def sources_iterator(self):
yield from AudioSource.all_visible.filter(event=self)
yield from ImageSource.all_visible.filter(event=self)
Expand Down Expand Up @@ -373,26 +387,6 @@ def entries_count(self):
return Entry.all_visible.filter(event=self).count()


class UsersEntryCollection(TimeStampedModel):
"""
Users are allowed to create and manage their private collections. They may share them with others, too!
"""
class Meta:
verbose_name = _('user_entry_collection')
verbose_name_plural = _('user_entry_collections')

user = models.ForeignKey(User, related_name='collections', on_delete=models.CASCADE)
name = models.CharField(max_length=250)
public = models.BooleanField(default=False)
starred = models.BooleanField(default=False)

def save(self, **kwargs):
if self.starred:
if UsersEntryCollection.objects.exclude(pk=self.id).filter(user_id=self.user_id, starred=True).exists():
raise IntegrityError("There can be only one starred collection per user.")
return super(UsersEntryCollection, self).save(**kwargs)


class Entry(TimeStampedModel, Taggable, Content):
"""
A single Entry represents more or less one question and one answer given by fan and answered by author.
Expand Down Expand Up @@ -569,6 +563,28 @@ def update(self):
self.save()


class UsersEntryCollection(TimeStampedModel):
"""
Users are allowed to create and manage their private collections. They may share them with others, too!
"""
MAX_NAME_LENGTH = 250

class Meta:
verbose_name = _('user_entry_collection')
verbose_name_plural = _('user_entry_collections')
ordering = ('name',)

user = models.ForeignKey(User, related_name='collections', on_delete=models.CASCADE)
name = models.CharField(max_length=MAX_NAME_LENGTH)
description = models.TextField(default='', blank=True)
public = models.BooleanField(default=False)
entries = models.ManyToManyField(Entry, related_name='collections')

def save(self, **kwargs):
self.description = bleach.clean(self.description, strip=True, strip_comments=True)
super().save(**kwargs)


class EntryVersion(models.Model):
"""
This is one of the version an Entry can have. Versions are collections of EntryLines and represent history of
Expand Down
81 changes: 77 additions & 4 deletions palanaeum/sass/palanaeum.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ main {
color: darkblue;
}

table {
caption, thead th {
background-color: $theme-color;
color: $text-light;
}
td {
vertical-align: middle !important;
}
.narrow-col{
width: 50px;
text-align: center;
}
}

.input-table {
margin-top: 10px;
margin-bottom: 10px;
Expand All @@ -142,10 +156,6 @@ main {
border-bottom: 1px dotted #dddddd;
vertical-align: middle;
}
caption {
background-color: $theme-color;
color: $text-light;
}
input:not([type="submit"]):not([type="checkbox"]),
select,
textarea {
Expand Down Expand Up @@ -262,6 +272,7 @@ a.url-icon {
.entry-content {
text-align: left;
padding: 0 10px 0px 10px;
clear: left;
h4 {
font-weight: bold;
}
Expand Down Expand Up @@ -792,3 +803,65 @@ del {
padding: 10px;
text-align: center;
}

.collections-list {
.privacy-icon {
font-size: 2em;
text-align: center;
}
}


.ui-widget-header {
background: white !important;
color: black !important;
border-width: 0 !important;
}

#collections-dialog {
#collections-scroll-list {
display: block;
min-width: 150px;
min-height: 300px;
max-height: 300px;
overflow-y: auto;
padding: 2px;
width: 100%;
height: 100%;
input {
margin: 5px;
}
.collection-elem{
padding: 3px;
border-bottom: 1px solid whitesmoke;
.collection-elem-symbol {
float: right;
line-height: 38px;
}
}
}
button {
width: 100%;
}
#add-collection-input {
width: 100%;
input {
width: 83%;
border: 1px solid #a0a0a0;
height: 38px;
}
button {
width: 15%;
}
}
display: none;
border-top: 1px solid whitesmoke;
}

.ui-widget, .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button{
font family: 'Roboto', sans-serif;
}

.no-overflow {
word-break: break-word;
}
2 changes: 1 addition & 1 deletion palanaeum/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

RUNSERVERPLUS_SERVER_ADDRESS_PORT = '0.0.0.0:9000'

PALANAEUM_VERSION = '1.0.0'
PALANAEUM_VERSION = '1.1.0'


# Application definition
Expand Down
Loading

0 comments on commit d53bbc5

Please sign in to comment.