Commit 5651f644 authored by Mirko Vucicevich's avatar Mirko Vucicevich
Browse files

Merge branch 'master' into p01

parents 7032c4ae 1a4bd778
Testing / Staging
-----------------
To test changes in `master` branch:
```
ssh root@fast-t01.private.uwaterloo.ca
salt-call state.apply
```
Production
----------
Updating production to latest `p01` branch code:
```
ssh root@fast-p01.uwaterloo.ca
salt-call state.apply
```
Debug
-----
To view log files use `journacld`
```
journacld -f
```
Application code is found in: `/srv/<appname>/src`
...@@ -45,15 +45,16 @@ class NoticeInline(admin.StackedInline): ...@@ -45,15 +45,16 @@ class NoticeInline(admin.StackedInline):
class ProjectAdmin(admin.ModelAdmin): class ProjectAdmin(admin.ModelAdmin):
fieldsets = [ fieldsets = [
(None, {'fields': ['title']}), ('Project Information', {
('Project Icon', {'fields': ['icon']}), 'fields': ['title', 'icon', 'tagline', 'description', 'project_created']
('Tagline', {'fields': ['tagline']}), }),
('Gitlab ID', {'fields': ['gitlab_id']}), ('Project Details', {'fields': ['scope', 'technologies', 'groups']}),
('Hostnames', {'fields': ['hostnames']}), ('Overlay Information', {'fields': ['hostnames']}),
('Description', {'fields': ['description']}), ('Gitlab Integration', {
('Date information', {'fields': ['project_created']}), 'fields': ['gitlab_id', 'gitlab_access_token', 'gitlab_url'],
('Groups & Technologies', {'fields': ['technologies', 'groups']}), 'classes': ['collapse']
('Scope', {'fields': ['scope']}),
}),
] ]
filter_horizontal = ['technologies', 'groups'] filter_horizontal = ['technologies', 'groups']
......
# Generated by Django 2.2.6 on 2019-11-18 18:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('projector', '0029_auto_20191008_1826'),
]
operations = [
migrations.AddField(
model_name='project',
name='gitlab_access_token',
field=models.CharField(blank=True, help_text="If the default gitlab API token won't work for you, provide an alternative", max_length=256),
),
migrations.AddField(
model_name='project',
name='gitlab_url',
field=models.CharField(blank=True, help_text="If your project isn't in the UW git repo, you can provide an alternative gitlab url here.", max_length=256),
),
migrations.AlterField(
model_name='project',
name='description',
field=models.TextField(help_text='Markdown-formatted project description'),
),
migrations.AlterField(
model_name='project',
name='gitlab_id',
field=models.CharField(blank=True, help_text='This can be found under general project settings (its an integer). If you have a CHANGELOG.md file in the root of your repo it will be read.', max_length=100),
),
migrations.AlterField(
model_name='project',
name='groups',
field=models.ManyToManyField(help_text='Include or add all groups which work with this project from a development perspective', to='projector.Group'),
),
migrations.AlterField(
model_name='project',
name='hostnames',
field=models.TextField(blank=True, help_text='List of allowed domains. Separate by commas. Overlay will only work on these hosts'),
),
migrations.AlterField(
model_name='project',
name='project_created',
field=models.DateField(help_text='The approximate date this project started development or was launched. Only year / term will be used by site.'),
),
migrations.AlterField(
model_name='project',
name='scope',
field=models.CharField(blank=True, choices=[('Local', 'Local (Used by Faculty/Dept Internally)'), ('Cross-Department', 'Cross-Department (Invite only)'), ('Campus-Wide', 'Campus-Wide (Available to All)')], max_length=100),
),
migrations.AlterField(
model_name='project',
name='tagline',
field=models.CharField(help_text='Short, catchy sentence about the project', max_length=100),
),
]
from django.utils import timezone from django.utils import timezone
from django.utils.functional import cached_property
from django.db import models from django.db import models
from imagekit.models import ProcessedImageField from imagekit.models import ProcessedImageField
from imagekit.processors import ResizeToFill from imagekit.processors import ResizeToFill
...@@ -14,20 +15,27 @@ class Project(models.Model): ...@@ -14,20 +15,27 @@ class Project(models.Model):
blank=True, blank=True,
null=True, null=True,
) )
gitlab_id = models.CharField(max_length=100, blank=True)
title = models.CharField(max_length=250) title = models.CharField(max_length=250)
slug = models.SlugField(max_length=250, blank=True) slug = models.SlugField(max_length=250, blank=True)
tagline = models.CharField(max_length=100) tagline = models.CharField(
description = models.TextField() max_length=100,
help_text="Short, catchy sentence about the project"
)
description = models.TextField(
help_text="Markdown-formatted project description"
)
technologies = models.ManyToManyField('projector.Technology', blank=True) technologies = models.ManyToManyField('projector.Technology', blank=True)
project_created = models.DateField( project_created = models.DateField(
help_text="The approximate date this project started development or was launched." help_text="The approximate date this project started development or was launched. Only year / term will be used by site."
)
groups = models.ManyToManyField(
'projector.Group',
help_text='Include or add all groups which work with this project from a development perspective'
) )
groups = models.ManyToManyField('projector.Group')
SCOPES = ( SCOPES = (
('Local', 'Local'), ('Local', 'Local (Used by Faculty/Dept Internally)'),
('Cross-Department', 'Cross-Department'), ('Cross-Department', 'Cross-Department (Invite only)'),
('Campus-Wide', 'Campus-Wide'), ('Campus-Wide', 'Campus-Wide (Available to All)'),
) )
scope = models.CharField( scope = models.CharField(
max_length=100, max_length=100,
...@@ -35,9 +43,23 @@ class Project(models.Model): ...@@ -35,9 +43,23 @@ class Project(models.Model):
blank=True, blank=True,
) )
hostnames = models.TextField( hostnames = models.TextField(
help_text="List of allowed domains. Separate by commas.", help_text="List of allowed domains. Separate by commas. Overlay will only work on these hosts",
blank=True blank=True
) )
gitlab_id = models.CharField(
max_length=100, blank=True,
help_text="This can be found under general project settings (its an integer). If you have a CHANGELOG.md file in the root of your repo it will be read."
)
gitlab_access_token = models.CharField(
max_length=256,
blank=True,
help_text="If the default gitlab API token won't work for you, provide an alternative"
)
gitlab_url = models.CharField(
max_length=256,
blank=True,
help_text="If your project isn't in the UW git repo, you can provide an alternative gitlab url here."
)
@property @property
def active_notices(self): def active_notices(self):
...@@ -49,23 +71,32 @@ class Project(models.Model): ...@@ -49,23 +71,32 @@ class Project(models.Model):
@property @property
def html(self): def html(self):
return markdown.markdown(self.description) return markdown.markdown(self.description)
@property @property
def changelog(self): def changelog(self):
#if self.changelog_stuff if not self.gitlab_id:
return ''
changelog = get( changelog = get(
'{}/api/v4/projects/{}/repository/files/changelog.md/raw?ref=master'.format( '{}/api/v4/projects/{}/repository/files/CHANGELOG.md/raw?ref=master'.format(
settings.GITLAB_DEFAULT_URL, self.gitlab_id self.gitlab_url if self.gitlab_url else
settings.GITLAB_DEFAULT_URL,
self.gitlab_id
), ),
headers={ headers={
'PRIVATE-TOKEN': settings.GITLAB_DEFAULT_ACCESS_TOKEN, 'PRIVATE-TOKEN': self.gitlab_access_token
if self.gitlab_access_token
else settings.GITLAB_DEFAULT_ACCESS_TOKEN,
} }
) )
return changelog.text return changelog.text
@property @cached_property
def changelogmd(self): def changelogmd(self):
return markdown.markdown(self.changelog) try:
return markdown.markdown(self.changelog)
except:
return ''
class Notice(models.Model): class Notice(models.Model):
project = models.ForeignKey( project = models.ForeignKey(
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">Notifications <span class="badge badge-light">{{ project.active_notices.count }}</span></a> <a class="nav-link" id="pills-profile-tab" data-toggle="pill" href="#pills-profile" role="tab" aria-controls="pills-profile" aria-selected="false">Notifications <span class="badge badge-light">{{ project.active_notices.count }}</span></a>
</li> </li>
{% endif %} {% endif %}
{% if project.gitlab_id %} {% if project.gitlab_id and project.changelogmd %}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="pills-changelog-tab" data-toggle="pill" href="#pills-changelog" role="tab" aria-controls="pills-changelog" aria-selected="false">Change Log</a> <a class="nav-link" id="pills-changelog-tab" data-toggle="pill" href="#pills-changelog" role="tab" aria-controls="pills-changelog" aria-selected="false">Change Log</a>
</li> </li>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment