Skip to content

Commit

Permalink
Merge branch 'main' into mdit-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Apr 22, 2024
2 parents 322b368 + d470540 commit 925dc6e
Show file tree
Hide file tree
Showing 191 changed files with 4,398 additions and 2,127 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ repos:
]
files: ^requirements/.*\.txt$
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
rev: v3.15.2
hooks:
- id: pyupgrade
args: ['--keep-runtime-typing', '--py311-plus']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
rev: v0.4.1
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
Expand Down Expand Up @@ -102,7 +102,7 @@ repos:
additional_dependencies:
- tomli
- repo: https://github.com/psf/black
rev: 24.3.0
rev: 24.4.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
Expand Down Expand Up @@ -149,7 +149,7 @@ repos:
args:
- --external-sources
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ initpy-loginproviders:
initpy-transports:
# Do not auto-gen funnel/transports/__init__.py, only sub-packages
mkinit --inplace --relative --black funnel/transports/email
mkinit --inplace --relative --black funnel/transports/sms
mkinit --inplace --relative --black funnel/transports/sms
isort funnel/transports/*/__init__.py
black funnel/transports/*/__init__.py

Expand Down
16 changes: 8 additions & 8 deletions funnel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@

#: Main app for hasgeek.com
app = Flask(__name__, instance_relative_config=True)
app.name = 'funnel' # pyright: ignore[reportGeneralTypeIssues]
app.name = 'funnel' # pyright: ignore[reportAttributeAccessIssue]
app.config['SITE_TITLE'] = __("Hasgeek")
#: Short link app at has.gy
shortlinkapp = Flask(__name__, static_folder=None, instance_relative_config=True)
shortlinkapp.name = 'shortlink' # pyright: ignore[reportGeneralTypeIssues]
shortlinkapp.name = 'shortlink' # pyright: ignore[reportAttributeAccessIssue]
#: Unsubscribe app at bye.li
unsubscribeapp = Flask(__name__, static_folder=None, instance_relative_config=True)
unsubscribeapp.name = 'unsubscribe' # pyright: ignore[reportGeneralTypeIssues]
unsubscribeapp.name = 'unsubscribe' # pyright: ignore[reportAttributeAccessIssue]

all_apps = [app, shortlinkapp, unsubscribeapp]

Expand All @@ -47,7 +47,7 @@
rq.queues = ['funnel'] # Queues used in this app
executor = Executor()

# --- Assets ---------------------------------------------------------------------------
# MARK: Assets -------------------------------------------------------------------------

#: Theme files, for transitioning away from Baseframe templates. These are used by
#: Baseframe's render_form and other form helper functions.
Expand All @@ -66,7 +66,7 @@
assets['schedules.js'][version] = 'js/schedules.js'


# --- Import rest of the app -----------------------------------------------------------
# MARK: Import rest of the app ---------------------------------------------------------

from . import ( # isort:skip # noqa: F401 # pylint: disable=wrong-import-position
geoip,
Expand All @@ -81,7 +81,7 @@
)
from .models import db, sa_orm # isort:skip

# --- Configuration---------------------------------------------------------------------
# MARK: Configuration ------------------------------------------------------------------

# Config is loaded from legacy Python settings files in the instance folder and then
# overridden with values from the environment. Python config is pending deprecation
Expand Down Expand Up @@ -197,13 +197,13 @@

views.siteadmin.init_rq_dashboard()

# --- Serve static files with WhiteNoise -----------------------------------------------
# MARK: Serve static files with WhiteNoise ---------------------------------------------

_wn = WhiteNoise(app.wsgi_app, root=app.static_folder, prefix=app.static_url_path)
_wn.add_files(baseframe.static_folder, prefix=baseframe.static_url_path)
app.wsgi_app = _wn # type: ignore[method-assign]

# --- Init SQLAlchemy mappers ----------------------------------------------------------
# MARK: Init SQLAlchemy mappers --------------------------------------------------------

# Database model loading (from Funnel or extensions) is complete.
# Configure database mappers now, before the process is forked for workers.
Expand Down
3 changes: 0 additions & 3 deletions funnel/assets/js/autosave_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ window.Hasgeek.autoSave = ({ autosave, formId, msgElemId }) => {
if (remoteData.revision) {
$('input[name="form.revision"]').val(remoteData.revision);
}
if (remoteData.form_nonce) {
$('input[name="form_nonce"]').val(remoteData.form_nonce);
}
waitingForResponse = false;
}
} else {
Expand Down
119 changes: 119 additions & 0 deletions funnel/assets/js/profile_calendar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import Vue from 'vue/dist/vue.min';
import FullCalendar from '@fullcalendar/vue';
import dayGridPlugin from '@fullcalendar/daygrid';
import multiMonthPlugin from '@fullcalendar/multimonth';
import { faSvg } from './utils/vue_util';

$(() => {
/* eslint-disable no-new */
const calendarApp = new Vue({
el: '#calendar',
components: {
FullCalendar,
faSvg,
},
data() {
return {
date: '',
showFilter: false,
calendarView: 'monthly',
access: 'both',
cfp: '',
events: [],
calendarOptions: {
plugins: [dayGridPlugin, multiMonthPlugin],
initialView: 'dayGridMonth',
aspectRatio: 1.5,
headerToolbar: {
start: 'title',
center: '',
end: '',
},
showNonCurrentDates: false,
dayMaxEventRows: 1,
events: async function fetchEvents(info) {
const url = `${window.location.href}?${new URLSearchParams({
start: info.startStr,
end: info.endStr,
}).toString()}`;
const response = await fetch(url, {
headers: {
Accept: 'application/json',
'X-Requested-With': 'XMLHttpRequest',
},
});
if (response && response.ok) {
const responseData = await response.json();
calendarApp.events = responseData;
return responseData;
}
return false;
},
eventTimeFormat: {
// like '14:30:00'
hour: '2-digit',
minute: '2-digit',
meridiem: 'short',
},
},
};
},
mounted() {
this.calendar = this.$refs.fullCalendar.getApi();
this.updateTitle();
},
methods: {
updateTitle() {
this.date = this.calendar.currentData.viewTitle;
},
updateEvents() {
this.events = this.calendar.getEvents();
},
prev() {
this.calendar.prev();
this.updateTitle();
},
next() {
this.calendar.next();
this.updateTitle();
},
toggleFilterMenu() {
this.showFilter = !this.showFilter;
},
applyFilter() {
this.showFilter = false; // Close filter menu
switch (this.calendarView) {
case 'monthly':
this.calendar.changeView('dayGridMonth');
break;
case 'yearly':
this.calendar.changeView('multiMonthYear');
break;
default:
this.calendar.changeView('dayGridMonth');
}
this.updateTitle();
this.updateEvents();
},
propertyVal(event, key) {
return (
event && (event[key] || (event.extendedProps && event.extendedProps[key]))
);
},
},
computed: {
filteredEvents() {
return this.events
.filter((event) => {
if (this.access === 'member') return event.member_access;
if (this.access === 'free') return !event.member_access;
return event;
})
.filter((event) => {
if (this.cfp) return event.cfp_open === this.cfp;
return event;
});
},
},
});
});
1 change: 0 additions & 1 deletion funnel/assets/js/submission.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const Submission = {
toastr.success(responseData.message);
}
$('.js-subscribed, .js-unsubscribed').toggleClass('mui--hide');
Form.updateFormNonce(responseData);
}
} else {
Form.getFetchError(response);
Expand Down
3 changes: 1 addition & 2 deletions funnel/assets/js/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ const Updates = {
},
handlePinEvent(event, formId, postUrl) {
event.preventDefault();
const onSuccess = (response) => {
const onSuccess = () => {
this.update.is_pinned = !this.update.is_pinned;
Form.updateFormNonce(response);
};

const onError = (error) => {
Expand Down
3 changes: 1 addition & 2 deletions funnel/assets/js/utils/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const SaveProject = ({
postUrl = $(`#${formId}`).attr('action'),
config = {},
}) => {
const onSuccess = (response) => {
const onSuccess = () => {
$(`#${formId}`)
.find('button')
.prop('disabled', false)
Expand All @@ -25,7 +25,6 @@ const SaveProject = ({
}
}
});
Form.updateFormNonce(response);
};

const onError = (error) => {
Expand Down
6 changes: 0 additions & 6 deletions funnel/assets/js/utils/formhelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const Form = {
return errorMsg;
},
handleAjaxError(errorResponse) {
Form.updateFormNonce(errorResponse.responseJSON);
const errorMsg = Form.getResponseError(errorResponse);
return errorMsg;
},
Expand All @@ -62,11 +61,6 @@ const Form = {
getActionUrl(formId) {
return $(`#${formId}`).attr('action');
},
updateFormNonce(response) {
if (response && response.form_nonce) {
$('input[name="form_nonce"]').val(response.form_nonce);
}
},
preventSubmitOnEnter(id) {
$(`#${id}`).on('keyup keypress', (e) => {
const code = e.keyCode || e.which;
Expand Down
4 changes: 1 addition & 3 deletions funnel/assets/js/utils/jsonform.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const jsonForm = Vue.component('jsonform', {
const obj = {};
const formData = $(`#${this.formid}`).serializeArray();
formData.forEach((field) => {
if (field.name !== 'form_nonce' && field.name !== 'csrf_token')
obj[field.name] = field.value;
if (field.name !== 'csrf_token') obj[field.name] = field.value;
});
return JSON.stringify(obj);
},
Expand All @@ -32,7 +31,6 @@ const jsonForm = Vue.component('jsonform', {
contentType: 'application/json',
dataType: 'html',
formData: JSON.stringify({
form_nonce: formValues.get('form_nonce'),
csrf_token: formValues.get('csrf_token'),
form: form.getFormData(),
}),
Expand Down
1 change: 0 additions & 1 deletion funnel/assets/js/utils/ticket_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const Ticketing = {
() => {
window.Boxoffice.init({
org,
itemCollection: menuId,
menu: menuId,
paymentDesc: menuTitle,
user_name: userName,
Expand Down
1 change: 1 addition & 0 deletions funnel/assets/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@import 'components/menu';
@import 'components/search-field';
@import 'components/chip';
@import 'components/badge';
@import 'components/alert';
@import 'components/thumbnail';
@import 'components/tabs';
Expand Down
69 changes: 69 additions & 0 deletions funnel/assets/sass/components/_badge.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.badge {
position: relative;
color: $mui-text-hyperlink;
min-width: $mui-grid-padding;
line-height: $mui-grid-padding;
min-height: $mui-grid-padding;
text-align: center;
display: inline-block;
background-color: transparentize($mui-primary-color, 0.85);
border-radius: 2px;
padding: 0 $mui-grid-padding * 0.5;
font-size: 10px;
text-transform: uppercase;
font-weight: 600;
}

.badge--round {
border-radius: 50%;
width: 25px;
line-height: 25px;
padding: 0;
}

.badge--round-smaller {
width: 16px;
line-height: 16px;
}

.badge--tab {
margin-right: $mui-grid-padding * 0.25;
margin-left: $mui-grid-padding * 0.25;
border-radius: 16px;
padding: 0 4px;
width: auto;
line-height: inherit;
background: $mui-bg-color-primary;
border: 1px solid $mui-bg-color-dark;
background: $mui-bg-color-primary;
}

.badge-accent {
background-color: $mui-bg-color-accent;
color: $mui-text-dark;
}

.badge-light {
background-color: $mui-bg-color-dark;
color: $mui-text-dark;
}

.badge-dark {
background-color: $mui-bg-color-dark;
color: $mui-text-dark;
}

.badge-danger {
background-color: $mui-danger-color;
color: mui-color('white');
}

.badge-success {
background-color: $mui-success-color;
border-color: transparentize($mui-text-success, 0.8);
color: $mui-text-success;
}

.badge + .badge {
margin-left: $mui-btn-spacing-horizontal;
}
Loading

0 comments on commit 925dc6e

Please sign in to comment.